diff --git a/AQLevelMeter.h b/AQLevelMeter.h new file mode 100644 index 0000000..68558fe --- /dev/null +++ b/AQLevelMeter.h @@ -0,0 +1,89 @@ +/* + + File: AQLevelMeter.h +Abstract: Class for handling and displaying AudioQueue meter data + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + + + +#import +#import + +#include "MeterTable.h" +#import "CAXException.h" + +#define kPeakFalloffPerSec .7 +#define kLevelFalloffPerSec .8 +#define kMinDBvalue -80.0 + +// A LevelMeter subclass which is used specifically for AudioQueue objects +@interface AQLevelMeter : UIView { + AudioQueueRef _aq; + AudioQueueLevelMeterState *_chan_lvls; + NSArray *_channelNumbers; + NSArray *_subLevelMeters; + MeterTable *_meterTable; + NSTimer *_updateTimer; + CGFloat _refreshHz; + BOOL _showsPeaks; + BOOL _vertical; + BOOL _useGL; + + UIColor *_bgColor, *_borderColor; + CFAbsoluteTime _peakFalloffLastFire; +} + +@property AudioQueueRef aq; // The AudioQueue object +@property CGFloat refreshHz; // How many times per second to redraw +@property (retain) NSArray *channelNumbers; // Array of NSNumber objects: The indices of the channels to display in this meter +@property BOOL showsPeaks; // Whether or not we show peak levels +@property BOOL vertical; // Whether the view is oriented V or H +@property BOOL useGL; // Whether or not to use OpenGL for drawing + +-(void)setBorderColor: (UIColor *)borderColor; +-(void)setBackgroundColor: (UIColor *)backgroundColor; + +@end diff --git a/AQLevelMeter.mm b/AQLevelMeter.mm new file mode 100644 index 0000000..19f1cb7 --- /dev/null +++ b/AQLevelMeter.mm @@ -0,0 +1,395 @@ +/* + + File: AQLevelMeter.mm +Abstract: n/a + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + + +#import "AQLevelMeter.h" + +#import "LevelMeter.h" +#import "GLLevelMeter.h" + +#import "CAStreamBasicDescription.h" + +@interface AQLevelMeter (AQLevelMeter_priv) +- (void)layoutSubLevelMeters; +@end + + +@implementation AQLevelMeter + +@synthesize showsPeaks = _showsPeaks; +@synthesize vertical = _vertical; + +- (id)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { + _refreshHz = 1. / 30.; + _showsPeaks = YES; + _channelNumbers = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:0], nil]; + _vertical = NO; + _useGL = YES; + _chan_lvls = (AudioQueueLevelMeterState*)malloc(sizeof(AudioQueueLevelMeterState) * [_channelNumbers count]); + _meterTable = new MeterTable(kMinDBvalue); + _bgColor = nil; + _borderColor = nil; + [self layoutSubLevelMeters]; + } + return self; +} + + +- (id)initWithCoder:(NSCoder *)coder { + if (self = [super initWithCoder:coder]) { + _refreshHz = 1. / 30.; + _showsPeaks = YES; + _channelNumbers = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:0], nil]; + _chan_lvls = (AudioQueueLevelMeterState*)malloc(sizeof(AudioQueueLevelMeterState) * [_channelNumbers count]); + _vertical = NO; + _useGL = YES; + _meterTable = new MeterTable(kMinDBvalue); + [self layoutSubLevelMeters]; + } + return self; +} + +//-(void)setBorderColor: (UIColor *)borderColor +//{ +// if (_borderColor) [_borderColor release]; +// _borderColor = borderColor; +// [_borderColor retain]; +// +// for (NSUInteger i=0; i < [_subLevelMeters count]; i++) +// { +// id meter = [_subLevelMeters objectAtIndex:i]; +// if (_useGL) +// { +// UIColor *oldColor = ((GLLevelMeter*)meter).borderColor; +// ((GLLevelMeter*)meter).borderColor = borderColor; +// [oldColor release]; +// } +// else +// { +// UIColor *oldColor = ((LevelMeter*)meter).borderColor; +// ((LevelMeter*)meter).borderColor = borderColor; +// [oldColor release]; +// } +// } +//} +// +//-(void)setBackgroundColor: (UIColor *)bgColor +//{ +// if (_bgColor) [_bgColor release]; +// _bgColor = bgColor; +// [_bgColor retain]; +// +// for (NSUInteger i=0; i < [_subLevelMeters count]; i++) +// { +// id meter = [_subLevelMeters objectAtIndex:i]; +// if (_useGL) +// ((GLLevelMeter*)meter).bgColor = bgColor; +// else +// ((LevelMeter*)meter).bgColor = bgColor; +// } +// +//} + +//- (void)layoutSubLevelMeters +//{ +// int i; +// for (i=0; i<[_subLevelMeters count]; i++) +// { +// UIView *thisMeter = [_subLevelMeters objectAtIndex:i]; +// [thisMeter removeFromSuperview]; +// } +// [_subLevelMeters release]; +// +// NSMutableArray *meters_build = [[NSMutableArray alloc] initWithCapacity:[_channelNumbers count]]; +// +// CGRect totalRect; +// +// if (_vertical) totalRect = CGRectMake(0., 0., [self frame].size.width + 2., [self frame].size.height); +// else totalRect = CGRectMake(0., 0., [self frame].size.width, [self frame].size.height + 2.); +// +// for (i=0; i<[_channelNumbers count]; i++) +// { +// CGRect fr; +// +// if (_vertical) { +// fr = CGRectMake( +// totalRect.origin.x + (((CGFloat)i / (CGFloat)[_channelNumbers count]) * totalRect.size.width), +// totalRect.origin.y, +// (1. / (CGFloat)[_channelNumbers count]) * totalRect.size.width - 2., +// totalRect.size.height +// ); +// } else { +// fr = CGRectMake( +// totalRect.origin.x, +// totalRect.origin.y + (((CGFloat)i / (CGFloat)[_channelNumbers count]) * totalRect.size.height), +// totalRect.size.width, +// (1. / (CGFloat)[_channelNumbers count]) * totalRect.size.height - 2. +// ); +// } +// +// LevelMeter *newMeter; +// +// if (_useGL) newMeter = [[GLLevelMeter alloc] initWithFrame:fr]; +// else newMeter = [[LevelMeter alloc] initWithFrame:fr]; +// +// newMeter.numLights = 30; +// newMeter.vertical = self.vertical; +// newMeter.bgColor = _bgColor; +// newMeter.borderColor = _borderColor; +// +// [meters_build addObject:newMeter]; +// [self addSubview:newMeter]; +// [newMeter release]; +// } +// +// _subLevelMeters = [[NSArray alloc] initWithArray:meters_build]; +// +// [meters_build release]; +//} + + +- (void)_refresh +{ + BOOL success = NO; + + // if we have no queue, but still have levels, gradually bring them down + if (_aq == NULL) + { + CGFloat maxLvl = -1.; + CFAbsoluteTime thisFire = CFAbsoluteTimeGetCurrent(); + // calculate how much time passed since the last draw + CFAbsoluteTime timePassed = thisFire - _peakFalloffLastFire; + for (LevelMeter *thisMeter in _subLevelMeters) + { + CGFloat newPeak, newLevel; + newLevel = thisMeter.level - timePassed * kLevelFalloffPerSec; + if (newLevel < 0.) newLevel = 0.; + thisMeter.level = newLevel; + if (_showsPeaks) + { + newPeak = thisMeter.peakLevel - timePassed * kPeakFalloffPerSec; + if (newPeak < 0.) newPeak = 0.; + thisMeter.peakLevel = newPeak; + if (newPeak > maxLvl) maxLvl = newPeak; + } + else if (newLevel > maxLvl) maxLvl = newLevel; + + [thisMeter setNeedsDisplay]; + } + // stop the timer when the last level has hit 0 + if (maxLvl <= 0.) + { + [_updateTimer invalidate]; + _updateTimer = nil; + } + + _peakFalloffLastFire = thisFire; + success = YES; + } else { + + + // ============================ THIS IS IT!!!!!!!!!!!!!!! kAudioQueueProperty_CurrentLevelMeterDB is THE + // current volume level. It's a property of an AudioQueue object or whatever. Just read about it in the + // Audio Toolbox framework reference, under the Audio Queue Services section. + // ============================================================= +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + UInt32 data_sz = sizeof(AudioQueueLevelMeterState) * [_channelNumbers count]; + + OSErr status = AudioQueueGetProperty(_aq, kAudioQueueProperty_CurrentLevelMeterDB, _chan_lvls, &data_sz); + if (status != noErr) goto bail; + + for (int i=0; i<[_channelNumbers count]; i++) + { + NSInteger channelIdx = [(NSNumber *)[_channelNumbers objectAtIndex:i] intValue]; + //LevelMeter *channelView = [_subLevelMeters objectAtIndex:channelIdx]; + + if (channelIdx >= [_channelNumbers count]) goto bail; + if (channelIdx > 127) goto bail; + + if (_chan_lvls) + { + //channelView.level = _meterTable->ValueAt((float)(_chan_lvls[channelIdx].mAveragePower)); + + // ========================== IT SHOULD PRINT THE CURRENT VOLUME HERE. ============== + printf("%f\n", _chan_lvls[channelIdx].mAveragePower); + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + +// if (_showsPeaks) channelView.peakLevel = _meterTable->ValueAt((float)(_chan_lvls[channelIdx].mPeakPower)); +// else channelView.peakLevel = 0.; +// [channelView setNeedsDisplay]; +// success = YES; + } + + } + } + +bail: + + if (!success) + { + for (LevelMeter *thisMeter in _subLevelMeters) { thisMeter.level = 0.; [thisMeter setNeedsDisplay]; } + printf("ERROR: metering failed\n"); + } +} + + +- (void)dealloc +{ + [_updateTimer invalidate]; + [_channelNumbers release]; + [_subLevelMeters release]; + [_bgColor release]; + [_borderColor release]; + + delete _meterTable; + + [super dealloc]; +} + + +- (AudioQueueRef)aq +{ + return _aq; +} + +- (void)setAq:(AudioQueueRef)v +{ + if ((_aq == NULL) && (v != NULL)) + { + if (_updateTimer) { + [_updateTimer invalidate]; + } + _updateTimer = [NSTimer + scheduledTimerWithTimeInterval:_refreshHz + target:self + selector:@selector(_refresh) + userInfo:nil + repeats:YES + ]; + } else if ((_aq != NULL) && (v == NULL)) { + _peakFalloffLastFire = CFAbsoluteTimeGetCurrent(); + } + + _aq = v; + + if (_aq) + { + try { + UInt32 val = 1; + XThrowIfError(AudioQueueSetProperty(_aq, kAudioQueueProperty_EnableLevelMetering, &val, sizeof(UInt32)), "couldn't enable metering"); + + // now check the number of channels in the new queue, we will need to reallocate if this has changed + CAStreamBasicDescription queueFormat; + UInt32 data_sz = sizeof(queueFormat); + XThrowIfError(AudioQueueGetProperty(_aq, kAudioQueueProperty_StreamDescription, &queueFormat, &data_sz), "couldn't get stream description"); + + if (queueFormat.NumberChannels() != [_channelNumbers count]) + { + NSArray *chan_array; + if (queueFormat.NumberChannels() < 2) + chan_array = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:0], nil]; + else + chan_array = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:0], [NSNumber numberWithInt:1], nil]; + + [self setChannelNumbers:chan_array]; + [chan_array release]; + + _chan_lvls = (AudioQueueLevelMeterState*)realloc(_chan_lvls, queueFormat.NumberChannels() * sizeof(AudioQueueLevelMeterState)); + } + } + catch (CAXException e) { + char buf[256]; + fprintf(stderr, "Error: %s (%s)\n", e.mOperation, e.FormatError(buf)); + } + } else { + for (LevelMeter *thisMeter in _subLevelMeters) { + [thisMeter setNeedsDisplay]; + } + } +} + +- (CGFloat)refreshHz { return _refreshHz; } +- (void)setRefreshHz:(CGFloat)v +{ + _refreshHz = v; + if (_updateTimer) + { + [_updateTimer invalidate]; + _updateTimer = [NSTimer + scheduledTimerWithTimeInterval:_refreshHz + target:self + selector:@selector(_refresh) + userInfo:nil + repeats:YES + ]; + } +} + + +- (NSArray *)channelNumbers { return _channelNumbers; } +- (void)setChannelNumbers:(NSArray *)v +{ + [v retain]; + [_channelNumbers release]; + _channelNumbers = v; + [self layoutSubLevelMeters]; +} + +- (BOOL)useGL { return _useGL; } +- (void)setUseGL:(BOOL)v +{ + _useGL = v; + [self layoutSubLevelMeters]; +} + +@end diff --git a/AQPlayer.h b/AQPlayer.h new file mode 100644 index 0000000..1f9fb6b --- /dev/null +++ b/AQPlayer.h @@ -0,0 +1,110 @@ +/* + + File: AQPlayer.h +Abstract: Helper class for playing audio files via the AudioQueue + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#include + +#include "CAStreamBasicDescription.h" +#include "CAXException.h" + +#define kNumberBuffers 3 + +class AQPlayer + { + public: + AQPlayer(); + ~AQPlayer(); + + OSStatus StartQueue(Boolean inResume); + OSStatus StopQueue(); + + AudioQueueRef Queue() { return mQueue; } + CAStreamBasicDescription DataFormat() const { return mDataFormat; } + Boolean IsRunning() const { return (mIsRunning) ? true : false; } + Boolean IsInitialized() const { return mIsInitialized; } + CFStringRef GetFilePath() const { return (mFilePath) ? mFilePath : CFSTR(""); } + Boolean IsLooping() const { return mIsLooping; } + + void SetLooping(Boolean inIsLooping) { mIsLooping = inIsLooping; } + void CreateQueueForFile(CFStringRef inFilePath); + void DisposeQueue(Boolean inDisposeFile); + + private: + UInt32 GetNumPacketsToRead() { return mNumPacketsToRead; } + SInt64 GetCurrentPacket() { return mCurrentPacket; } + AudioFileID GetAudioFileID() { return mAudioFile; } + void SetCurrentPacket(SInt64 inPacket) { mCurrentPacket = inPacket; } + + void SetupNewQueue(); + + AudioQueueRef mQueue; + AudioQueueBufferRef mBuffers[kNumberBuffers]; + AudioFileID mAudioFile; + CFStringRef mFilePath; + CAStreamBasicDescription mDataFormat; + Boolean mIsInitialized; + UInt32 mNumPacketsToRead; + SInt64 mCurrentPacket; + UInt32 mIsRunning; + Boolean mIsDone; + Boolean mIsLooping; + + static void isRunningProc( void * inUserData, + AudioQueueRef inAQ, + AudioQueuePropertyID inID); + + static void AQBufferCallback( void * inUserData, + AudioQueueRef inAQ, + AudioQueueBufferRef inCompleteAQBuffer); + + void CalculateBytesForTime( CAStreamBasicDescription & inDesc, + UInt32 inMaxPacketSize, + Float64 inSeconds, + UInt32 *outBufferSize, + UInt32 *outNumPackets); + }; \ No newline at end of file diff --git a/AQPlayer.mm b/AQPlayer.mm new file mode 100755 index 0000000..f9174a7 --- /dev/null +++ b/AQPlayer.mm @@ -0,0 +1,286 @@ +/* + + File: AQPlayer.mm +Abstract: n/a + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + + +#include "AQPlayer.h" + +void AQPlayer::AQBufferCallback(void * inUserData, + AudioQueueRef inAQ, + AudioQueueBufferRef inCompleteAQBuffer) +{ + AQPlayer *THIS = (AQPlayer *)inUserData; + + if (THIS->mIsDone) return; + + UInt32 numBytes; + UInt32 nPackets = THIS->GetNumPacketsToRead(); + OSStatus result = AudioFileReadPackets(THIS->GetAudioFileID(), false, &numBytes, inCompleteAQBuffer->mPacketDescriptions, THIS->GetCurrentPacket(), &nPackets, + inCompleteAQBuffer->mAudioData); + if (result) + printf("AudioFileReadPackets failed: %d", result); + if (nPackets > 0) { + inCompleteAQBuffer->mAudioDataByteSize = numBytes; + inCompleteAQBuffer->mPacketDescriptionCount = nPackets; + AudioQueueEnqueueBuffer(inAQ, inCompleteAQBuffer, 0, NULL); + THIS->mCurrentPacket = (THIS->GetCurrentPacket() + nPackets); + } + + else + { + if (THIS->IsLooping()) + { + THIS->mCurrentPacket = 0; + AQBufferCallback(inUserData, inAQ, inCompleteAQBuffer); + } + else + { + // stop + THIS->mIsDone = true; + AudioQueueStop(inAQ, false); + } + } +} + +void AQPlayer::isRunningProc ( void * inUserData, + AudioQueueRef inAQ, + AudioQueuePropertyID inID) +{ + AQPlayer *THIS = (AQPlayer *)inUserData; + UInt32 size = sizeof(THIS->mIsRunning); + OSStatus result = AudioQueueGetProperty (inAQ, kAudioQueueProperty_IsRunning, &THIS->mIsRunning, &size); + + if ((result == noErr) && (!THIS->mIsRunning)) + [[NSNotificationCenter defaultCenter] postNotificationName: @"playbackQueueStopped" object: nil]; +} + +void AQPlayer::CalculateBytesForTime (CAStreamBasicDescription & inDesc, UInt32 inMaxPacketSize, Float64 inSeconds, UInt32 *outBufferSize, UInt32 *outNumPackets) +{ + // we only use time here as a guideline + // we're really trying to get somewhere between 16K and 64K buffers, but not allocate too much if we don't need it + static const int maxBufferSize = 0x10000; // limit size to 64K + static const int minBufferSize = 0x4000; // limit size to 16K + + if (inDesc.mFramesPerPacket) { + Float64 numPacketsForTime = inDesc.mSampleRate / inDesc.mFramesPerPacket * inSeconds; + *outBufferSize = numPacketsForTime * inMaxPacketSize; + } else { + // if frames per packet is zero, then the codec has no predictable packet == time + // so we can't tailor this (we don't know how many Packets represent a time period + // we'll just return a default buffer size + *outBufferSize = maxBufferSize > inMaxPacketSize ? maxBufferSize : inMaxPacketSize; + } + + // we're going to limit our size to our default + if (*outBufferSize > maxBufferSize && *outBufferSize > inMaxPacketSize) + *outBufferSize = maxBufferSize; + else { + // also make sure we're not too small - we don't want to go the disk for too small chunks + if (*outBufferSize < minBufferSize) + *outBufferSize = minBufferSize; + } + *outNumPackets = *outBufferSize / inMaxPacketSize; +} + +AQPlayer::AQPlayer() : + mQueue(0), + mAudioFile(0), + mFilePath(NULL), + mIsRunning(false), + mIsInitialized(false), + mNumPacketsToRead(0), + mCurrentPacket(0), + mIsDone(false), + mIsLooping(false) { } + +AQPlayer::~AQPlayer() +{ + DisposeQueue(true); +} + +OSStatus AQPlayer::StartQueue(Boolean inResume) +{ + // if we have a file but no queue, create one now + if ((mQueue == NULL) && (mFilePath != NULL)) + CreateQueueForFile(mFilePath); + + UInt32 category = kAudioSessionCategory_MediaPlayback; + OSStatus result = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category); + if (result) printf("ERROR SETTING AUDIO CATEGORY!\n"); + + result = AudioSessionSetActive(true); + if (result) printf("ERROR SETTING AUDIO SESSION ACTIVE!\n"); + + mIsDone = false; + + // if we are not resuming, we also should restart the file read index + if (!inResume) + mCurrentPacket = 0; + + // prime the queue with some data before starting + for (int i = 0; i < kNumberBuffers; ++i) { + AQBufferCallback (this, mQueue, mBuffers[i]); + } + return AudioQueueStart(mQueue, NULL); +} + +OSStatus AQPlayer::StopQueue() +{ + OSStatus result = AudioQueueStop(mQueue, true); + if (result) printf("ERROR STOPPING QUEUE!\n"); + else + { + result = AudioSessionSetActive(false); + if (result) printf("ERROR SETTING AUDIO SESSION INACTIVE!\n"); + } + return result; +} + +void AQPlayer::CreateQueueForFile(CFStringRef inFilePath) +{ + CFURLRef sndFile = NULL; + + try { + if (mFilePath == NULL) + { + mIsLooping = false; + + sndFile = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, inFilePath, kCFURLPOSIXPathStyle, false); + if (!sndFile) { printf("can't parse file path\n"); return; } + + XThrowIfError(AudioFileOpenURL (sndFile, kAudioFileReadPermission, 0/*inFileTypeHint*/, &mAudioFile), "can't open file"); + + UInt32 size = sizeof(mDataFormat); + XThrowIfError(AudioFileGetProperty(mAudioFile, + kAudioFilePropertyDataFormat, &size, &mDataFormat), "couldn't get file's data format"); + mFilePath = CFStringCreateCopy(kCFAllocatorDefault, inFilePath); + } + SetupNewQueue(); + } + catch (CAXException e) { + char buf[256]; + fprintf(stderr, "Error: %s (%s)\n", e.mOperation, e.FormatError(buf)); + } + if (sndFile) + CFRelease(sndFile); +} + +void AQPlayer::SetupNewQueue() +{ + XThrowIfError(AudioQueueNewOutput(&mDataFormat, AQPlayer::AQBufferCallback, this, + CFRunLoopGetCurrent(), kCFRunLoopCommonModes, 0, &mQueue), "AudioQueueNew failed"); + UInt32 bufferByteSize; + // we need to calculate how many packets we read at a time, and how big a buffer we need + // we base this on the size of the packets in the file and an approximate duration for each buffer + // first check to see what the max size of a packet is - if it is bigger + // than our allocation default size, that needs to become larger + UInt32 maxPacketSize; + UInt32 size = sizeof(maxPacketSize); + XThrowIfError(AudioFileGetProperty(mAudioFile, + kAudioFilePropertyPacketSizeUpperBound, &size, &maxPacketSize), "couldn't get file's max packet size"); + + // adjust buffer size to represent about a half second of audio based on this format + CalculateBytesForTime (mDataFormat, maxPacketSize, .5, &bufferByteSize, &mNumPacketsToRead); + + //printf ("Buffer Byte Size: %d, Num Packets to Read: %d\n", (int)bufferByteSize, (int)mNumPacketsToRead); + + // (2) If the file has a cookie, we should get it and set it on the AQ + size = sizeof(UInt32); + OSStatus result = AudioFileGetPropertyInfo (mAudioFile, kAudioFilePropertyMagicCookieData, &size, NULL); + + if (!result && size) { + char* cookie = new char [size]; + XThrowIfError (AudioFileGetProperty (mAudioFile, kAudioFilePropertyMagicCookieData, &size, cookie), "get cookie from file"); + XThrowIfError (AudioQueueSetProperty(mQueue, kAudioQueueProperty_MagicCookie, cookie, size), "set cookie on queue"); + delete [] cookie; + } + + // channel layout? + result = AudioFileGetPropertyInfo(mAudioFile, kAudioFilePropertyChannelLayout, &size, NULL); + if (result == noErr && size > 0) { + AudioChannelLayout *acl = (AudioChannelLayout *)malloc(size); + XThrowIfError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyChannelLayout, &size, acl), "get audio file's channel layout"); + XThrowIfError(AudioQueueSetProperty(mQueue, kAudioQueueProperty_ChannelLayout, acl, size), "set channel layout on queue"); + free(acl); + } + + XThrowIfError(AudioQueueAddPropertyListener(mQueue, kAudioQueueProperty_IsRunning, isRunningProc, this), "adding property listener"); + + bool isFormatVBR = (mDataFormat.mBytesPerPacket == 0 || mDataFormat.mFramesPerPacket == 0); + for (int i = 0; i < kNumberBuffers; ++i) { + XThrowIfError(AudioQueueAllocateBufferWithPacketDescriptions(mQueue, bufferByteSize, (isFormatVBR ? mNumPacketsToRead : 0), &mBuffers[i]), "AudioQueueAllocateBuffer failed"); + } + + // set the volume of the queue + XThrowIfError (AudioQueueSetParameter(mQueue, kAudioQueueParam_Volume, 1.0), "set queue volume"); + + mIsInitialized = true; +} + +void AQPlayer::DisposeQueue(Boolean inDisposeFile) +{ + if (mQueue) + { + AudioQueueDispose(mQueue, true); + mQueue = NULL; + } + if (inDisposeFile) + { + if (mAudioFile) + { + AudioFileClose(mAudioFile); + mAudioFile = 0; + } + if (mFilePath) + { + CFRelease(mFilePath); + mFilePath = NULL; + } + } + mIsInitialized = false; +} \ No newline at end of file diff --git a/AQRecorder.h b/AQRecorder.h new file mode 100755 index 0000000..97d00e7 --- /dev/null +++ b/AQRecorder.h @@ -0,0 +1,95 @@ +/* + + File: AQRecorder.h +Abstract: Helper class for recording audio files via the AudioQueue + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#include +#include +#include + +#include "CAStreamBasicDescription.h" +#include "CAXException.h" + +#define kNumberRecordBuffers 3 + +class AQRecorder + { + public: + AQRecorder(); + ~AQRecorder(); + + UInt32 GetNumberChannels() const { return mRecordFormat.NumberChannels(); } + CFStringRef GetFileName() const { return mFileName; } + AudioQueueRef Queue() const { return mQueue; } + CAStreamBasicDescription DataFormat() const { return mRecordFormat; } + + void StartRecord(CFStringRef inRecordFile); + void StopRecord(); + Boolean IsRunning() const { return mIsRunning; } + + UInt64 startTime; + + private: + void CopyEncoderCookieToFile(); + CAStreamBasicDescription SetupAudioFormat(UInt32 inFormatID); + int ComputeRecordBufferSize(const AudioStreamBasicDescription *format, float seconds); + + CFStringRef mFileName; + AudioQueueRef mQueue; + AudioQueueBufferRef mBuffers[kNumberRecordBuffers]; + AudioFileID mRecordFile; + SInt64 mRecordPacket; // current packet number in record file + CAStreamBasicDescription mRecordFormat; + Boolean mIsRunning; + + static void MyInputBufferHandler( void * inUserData, + AudioQueueRef inAQ, + AudioQueueBufferRef inBuffer, + const AudioTimeStamp * inStartTime, + UInt32 inNumPackets, + const AudioStreamPacketDescription* inPacketDesc); + }; \ No newline at end of file diff --git a/AQRecorder.mm b/AQRecorder.mm new file mode 100755 index 0000000..385f189 --- /dev/null +++ b/AQRecorder.mm @@ -0,0 +1,268 @@ +/* + + File: AQRecorder.mm +Abstract: n/a + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#include "AQRecorder.h" + +// ____________________________________________________________________________________ +// Determine the size, in bytes, of a buffer necessary to represent the supplied number +// of seconds of audio data. +int AQRecorder::ComputeRecordBufferSize(const AudioStreamBasicDescription *format, float seconds) +{ + int packets, frames, bytes = 0; + try { + frames = (int)ceil(seconds * format->mSampleRate); + + if (format->mBytesPerFrame > 0) + bytes = frames * format->mBytesPerFrame; + else { + UInt32 maxPacketSize; + if (format->mBytesPerPacket > 0) + maxPacketSize = format->mBytesPerPacket; // constant packet size + else { + UInt32 propertySize = sizeof(maxPacketSize); + XThrowIfError(AudioQueueGetProperty(mQueue, kAudioQueueProperty_MaximumOutputPacketSize, &maxPacketSize, + &propertySize), "couldn't get queue's maximum output packet size"); + } + if (format->mFramesPerPacket > 0) + packets = frames / format->mFramesPerPacket; + else + packets = frames; // worst-case scenario: 1 frame in a packet + if (packets == 0) // sanity check + packets = 1; + bytes = packets * maxPacketSize; + } + } catch (CAXException e) { + char buf[256]; + fprintf(stderr, "Error: %s (%s)\n", e.mOperation, e.FormatError(buf)); + return 0; + } + return bytes; +} + +// ____________________________________________________________________________________ +// AudioQueue callback function, called when an input buffers has been filled. +void AQRecorder::MyInputBufferHandler( void * inUserData, + AudioQueueRef inAQ, + AudioQueueBufferRef inBuffer, + const AudioTimeStamp * inStartTime, + UInt32 inNumPackets, + const AudioStreamPacketDescription* inPacketDesc) +{ + AQRecorder *aqr = (AQRecorder *)inUserData; + try { + if (inNumPackets == 0) { + // write packets to file + XThrowIfError(AudioFileWritePackets(aqr->mRecordFile, FALSE, inBuffer->mAudioDataByteSize, + inPacketDesc, aqr->mRecordPacket, &inNumPackets, inBuffer->mAudioData), + "AudioFileWritePackets failed"); + aqr->mRecordPacket += inNumPackets; + } + + // if we're not stopping, re-enqueue the buffe so that it gets filled again + if (aqr->IsRunning()) + XThrowIfError(AudioQueueEnqueueBuffer(inAQ, inBuffer, 0, NULL), "AudioQueueEnqueueBuffer failed"); + } catch (CAXException e) { + char buf[256]; + fprintf(stderr, "Error: %s (%s)\n", e.mOperation, e.FormatError(buf)); + } +} + +AQRecorder::AQRecorder() +{ + mIsRunning = false; + mRecordPacket = 0; +} + +AQRecorder::~AQRecorder() +{ + AudioQueueDispose(mQueue, TRUE); + AudioFileClose(mRecordFile); + if (mFileName) CFRelease(mFileName); +} + +// ____________________________________________________________________________________ +// Copy a queue's encoder's magic cookie to an audio file. +void AQRecorder::CopyEncoderCookieToFile() +{ + UInt32 propertySize; + // get the magic cookie, if any, from the converter + OSStatus err = AudioQueueGetPropertySize(mQueue, kAudioQueueProperty_MagicCookie, &propertySize); + + // we can get a noErr result and also a propertySize == 0 + // -- if the file format does support magic cookies, but this file doesn't have one. + if (err == noErr && propertySize > 0) { + Byte *magicCookie = new Byte[propertySize]; + UInt32 magicCookieSize; + XThrowIfError(AudioQueueGetProperty(mQueue, kAudioQueueProperty_MagicCookie, magicCookie, &propertySize), "get audio converter's magic cookie"); + magicCookieSize = propertySize; // the converter lies and tell us the wrong size + + // now set the magic cookie on the output file + UInt32 willEatTheCookie = false; + // the converter wants to give us one; will the file take it? + err = AudioFileGetPropertyInfo(mRecordFile, kAudioFilePropertyMagicCookieData, NULL, &willEatTheCookie); + if (err == noErr && willEatTheCookie) { + err = AudioFileSetProperty(mRecordFile, kAudioFilePropertyMagicCookieData, magicCookieSize, magicCookie); + XThrowIfError(err, "set audio file's magic cookie"); + } + delete[] magicCookie; + } +} + +CAStreamBasicDescription AQRecorder::SetupAudioFormat(UInt32 inFormatID) +{ + CAStreamBasicDescription recordFormat; + + memset(&mRecordFormat, 0, sizeof(recordFormat)); + UInt32 size = sizeof(recordFormat.mSampleRate); + XThrowIfError(AudioSessionGetProperty( kAudioSessionProperty_CurrentHardwareSampleRate, + &size, + &recordFormat.mSampleRate), "couldn't get hardware sample rate"); + size = sizeof(recordFormat.mChannelsPerFrame); + XThrowIfError(AudioSessionGetProperty( kAudioSessionProperty_CurrentHardwareInputNumberChannels, + &size, + &recordFormat.mChannelsPerFrame), "couldn't get input channel count"); + + recordFormat.mFormatID = inFormatID; + if (inFormatID == kAudioFormatLinearPCM) + { + // if we want pcm, default to signed 16-bit little-endian + recordFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; + recordFormat.mBitsPerChannel = 16; + recordFormat.mBytesPerPacket = recordFormat.mBytesPerFrame = (recordFormat.mBitsPerChannel / 8) * recordFormat.mChannelsPerFrame; + recordFormat.mFramesPerPacket = 1; + } + + return recordFormat; +} + +void AQRecorder::StartRecord(CFStringRef inRecordFile) +{ + int i, bufferByteSize; + UInt32 size; + CFURLRef url; + + try { + UInt32 category = kAudioSessionCategory_RecordAudio; + XThrowIfError(AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category), "couldn't set audio category!"); + + XThrowIfError(AudioSessionSetActive(true), "AudioSessionSetActive (true) failed"); + + mFileName = CFStringCreateCopy(kCFAllocatorDefault, inRecordFile); + + // specify the recording format + mRecordFormat = SetupAudioFormat(kAudioFormatLinearPCM); + + // create the queue + XThrowIfError(AudioQueueNewInput( + &mRecordFormat, + MyInputBufferHandler, + this /* userData */, + NULL /* run loop */, NULL /* run loop mode */, + 0 /* flags */, &mQueue), "AudioQueueNewInput failed"); + + // get the record format back from the queue's audio converter -- + // the file may require a more specific stream description than was necessary to create the encoder. + mRecordPacket = 0; + + size = sizeof(mRecordFormat); + XThrowIfError(AudioQueueGetProperty(mQueue, kAudioQueueProperty_StreamDescription, + &mRecordFormat, &size), "couldn't get queue's format"); + + NSString *recordFile = [NSTemporaryDirectory() stringByAppendingPathComponent: (NSString*)inRecordFile]; + + url = CFURLCreateWithString(kCFAllocatorDefault, (CFStringRef)recordFile, NULL); + + // create the audio file + XThrowIfError(AudioFileCreateWithURL(url, kAudioFileCAFType, &mRecordFormat, kAudioFileFlags_EraseFile, + &mRecordFile), "AudioFileCreateWithURL failed"); + CFRelease(url); + + // copy the cookie first to give the file object as much info as we can about the data going in + // not necessary for pcm, but required for some compressed audio + CopyEncoderCookieToFile(); + + // allocate and enqueue buffers + bufferByteSize = ComputeRecordBufferSize(&mRecordFormat, .5); // enough bytes for half a second + for (i = 0; i < kNumberRecordBuffers; ++i) { + XThrowIfError(AudioQueueAllocateBuffer(mQueue, bufferByteSize, &mBuffers[i]), + "AudioQueueAllocateBuffer failed"); + XThrowIfError(AudioQueueEnqueueBuffer(mQueue, mBuffers[i], 0, NULL), + "AudioQueueEnqueueBuffer failed"); + } + // start the queue + mIsRunning = true; + XThrowIfError(AudioQueueStart(mQueue, NULL), "AudioQueueStart failed"); + } + catch (CAXException &e) { + char buf[256]; + fprintf(stderr, "Error: %s (%s)\n", e.mOperation, e.FormatError(buf)); + } + catch (...) { + fprintf(stderr, "An unknown error occurred\n"); + } + +} + +void AQRecorder::StopRecord() +{ + // end recording + mIsRunning = false; + XThrowIfError(AudioQueueStop(mQueue, true), "AudioQueueStop failed"); + // a codec may update its cookie at the end of an encoding session, so reapply it to the file now + CopyEncoderCookieToFile(); + if (mFileName) + { + CFRelease(mFileName); + mFileName = NULL; + } + AudioQueueDispose(mQueue, true); + AudioFileClose(mRecordFile); + XThrowIfError(AudioSessionSetActive(false), "AudioSessionSetActive (false) failed"); + +} diff --git a/AlarmRingingView.xib b/AlarmRingingView.xib new file mode 100644 index 0000000..e3e8e90 --- /dev/null +++ b/AlarmRingingView.xib @@ -0,0 +1,730 @@ + + + + 784 + 10D573 + 785 + 1038.29 + 460.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 110 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 292 + + YES + + + 256 + {{0, 322}, {320, 160}} + + NO + YES + 4 + YES + IBCocoaTouchFramework + + NSImage + alarmRingingBottomBar.png + + + + + 292 + {{20, 408}, {280, 22}} + + NO + YES + NO + IBCocoaTouchFramework + + + 1 + MSAxIDEAA + + 1 + + + + + 3 + MAA + + 1 + 10 + 1 + + + + 292 + {{20, 428}, {280, 22}} + + NO + YES + NO + IBCocoaTouchFramework + + + 1 + MSAxIDEAA + + + + + 1 + 10 + 1 + + + + 256 + {320, 320} + + NO + YES + 4 + YES + IBCocoaTouchFramework + + + + 292 + {{20, 328}, {280, 69}} + + NO + YES + NO + IBCocoaTouchFramework + <time> + + LucidaGrande-Bold + 58 + 16 + + + 3 + MQA + + + + 1 + NO + 10 + 1 + + + + 292 + {{0, 130}, {320, 65}} + + NO + IBCocoaTouchFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + NSImage + alarmOffButton.png + + + + + 292 + {{0, 15}, {320, 115}} + + NO + IBCocoaTouchFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + NSImage + snoozeButton.png + + + + {320, 480} + + + IBCocoaTouchFramework + + + + + YES + + + view + + + + 3 + + + + currentTimeField + + + + 13 + + + + offButtonTapped: + + + 7 + + 19 + + + + snoozeButtonTapped: + + + 7 + + 22 + + + + artworkImageView + + + + 25 + + + + songLabel + + + + 29 + + + + artistLabel + + + + 30 + + + + + YES + + 0 + + + + + + 1 + + + YES + + + + + + + + + + + + -1 + + + File's Owner + + + -2 + + + + + 12 + + + + + 17 + + + + + 18 + + + + + 24 + + + + + 26 + + + + + 27 + + + + + 28 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 12.IBPluginDependency + 17.IBPluginDependency + 18.IBPluginDependency + 27.IBPluginDependency + 28.IBPluginDependency + + + YES + AlarmRingingViewController + UIResponder + {{399, 73}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 30 + + + + YES + + AlarmRingingViewController + UIViewController + + YES + + YES + offButtonTapped: + snoozeButtonTapped: + + + YES + id + id + + + + YES + + YES + offButtonTapped: + snoozeButtonTapped: + + + YES + + offButtonTapped: + id + + + snoozeButtonTapped: + id + + + + + YES + + YES + artistLabel + artworkImageView + currentTimeField + songLabel + + + YES + UILabel + UIImageView + UILabel + UILabel + + + + YES + + YES + artistLabel + artworkImageView + currentTimeField + songLabel + + + YES + + artistLabel + UILabel + + + artworkImageView + UIImageView + + + currentTimeField + UILabel + + + songLabel + UILabel + + + + + IBProjectSource + AlarmRingingViewController.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSNetServices.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPort.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSStream.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSXMLParser.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + YES + + YES + alarmOffButton.png + alarmRingingBottomBar.png + snoozeButton.png + + + YES + {320, 65} + {320, 160} + {320, 115} + + + 110 + + diff --git a/AlarmRingingViewController.h b/AlarmRingingViewController.h new file mode 100644 index 0000000..6b30cb9 --- /dev/null +++ b/AlarmRingingViewController.h @@ -0,0 +1,25 @@ +// +// AlarmRingingViewController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 8/15/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import + + +@interface AlarmRingingViewController : UIViewController { + + IBOutlet UILabel *currentTimeField; + IBOutlet UIImageView *artworkImageView; + IBOutlet UILabel *songLabel; + IBOutlet UILabel *artistLabel; + + NSTimer *clockTimer; +} + +- (IBAction)offButtonTapped:(id)sender; +- (IBAction)snoozeButtonTapped:(id)sender; +- (void)setSongTextAndAlbumArtwork:(NSNotification *)theNotification; +@end diff --git a/AlarmRingingViewController.m b/AlarmRingingViewController.m new file mode 100644 index 0000000..9019623 --- /dev/null +++ b/AlarmRingingViewController.m @@ -0,0 +1,128 @@ +// +// AlarmRingingViewController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 8/15/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import "AlarmRingingViewController.h" +#import "AlarmController.h" +#import +#import "Constants.h" + +@implementation AlarmRingingViewController + +/* + // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + // Custom initialization + } + return self; +} +*/ + + +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad { + [super viewDidLoad]; + [UIApplication sharedApplication].statusBarHidden = YES; + + // Set the time on the clock thing and set it up to update itself. + if (!clockTimer) { + NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; + if ([[[NSCalendar currentCalendar] locale] timeIs24HourFormat]) + { + [dateFormatter setDateFormat:@"HH:mm:ss"]; + } else { + [dateFormatter setDateFormat:@"h:mma"]; + } + NSString *currentTime = [dateFormatter stringFromDate:[NSDate date]]; + + [self setSongTextAndAlbumArtwork:nil]; + [currentTimeField setText:currentTime]; + clockTimer = [NSTimer scheduledTimerWithTimeInterval:2 target:self + selector:@selector(updateCurrentTimeField:) + userInfo:nil repeats:YES]; + + [[MPMusicPlayerController applicationMusicPlayer] beginGeneratingPlaybackNotifications]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(setSongTextAndAlbumArtwork:) + name:MPMusicPlayerControllerNowPlayingItemDidChangeNotification + object:[MPMusicPlayerController applicationMusicPlayer]]; + + } +} + +- (void)setSongTextAndAlbumArtwork:(NSNotification *)theNotification +{ + songLabel.text = [[MPMusicPlayerController applicationMusicPlayer].nowPlayingItem valueForProperty:MPMediaItemPropertyTitle]; + artistLabel.text = [[MPMusicPlayerController applicationMusicPlayer].nowPlayingItem valueForProperty:MPMediaItemPropertyArtist]; + + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kEnableDynamiteMode] boolValue]) + { + artworkImageView.image = [UIImage imageNamed:@"dynamite.png"]; + } else { + UIImage *artwork = [[[MPMusicPlayerController applicationMusicPlayer].nowPlayingItem valueForProperty:MPMediaItemPropertyArtwork] imageWithSize:artworkImageView.frame.size]; + if (artwork) { + artworkImageView.image = artwork; +// NSLog(@"there's artwork!"); + } else { + artworkImageView.image = [UIImage imageNamed:@"NoArtwork.tif"]; +// NSLog(@"it can't find the artwork!"); + } + } +} + +- (void)updateCurrentTimeField:(NSTimer *)timer { + // Make a string with the current time. + NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; + [dateFormatter setDateFormat:@"h:mma"]; + NSString *currentTime = [dateFormatter stringFromDate:[NSDate date]]; + + if (![[currentTimeField text] isEqualToString:currentTime]) { + [currentTimeField setText:currentTime]; + //NSLog(@"updated clock."); + } +} + + +/* +// Override to allow orientations other than the default portrait orientation. +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations + return (interfaceOrientation == UIInterfaceOrientationPortrait); +} +*/ + +- (IBAction)offButtonTapped:(id)sender +{ + [[AlarmController sharedAlarmController] stopAlarm:self]; +} + +- (IBAction)snoozeButtonTapped:(id)sender +{ + [[AlarmController sharedAlarmController] snoozeAlarm:self]; +} + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; + [UIApplication sharedApplication].statusBarHidden = NO; +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/AlarmSettingsView-iPad.xib b/AlarmSettingsView-iPad.xib new file mode 100644 index 0000000..fddd3d4 --- /dev/null +++ b/AlarmSettingsView-iPad.xib @@ -0,0 +1,860 @@ + + + + 1024 + 10F569 + 788 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 117 + + + YES + + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + 292 + + YES + + + 292 + {{0, 44}, {320, 216}} + + + 1 + MCAwIDAAA + + NO + YES + YES + IBIPadFramework + 0 + 0 + 0 + + en_US + + + America/Los_Angeles + + VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ +y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ +5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g +8n/BkPNvwKD0X6OQ9U+ioPY/hZD3L4Sg+CiiEPkPZqD6CIQQ+viDIPvoZhD82GUg/chIEP64RyD/qCoQ +AJgpIAGIDBACeAsgA3EokARhJ6AFUQqQBkEJoAcw7JAHjUOgCRDOkAmtvyAK8LCQC+CvoAzZzRANwJGg +DrmvEA+priAQmZEQEYmQIBJ5cxATaXIgFFlVEBVJVCAWOTcQFyk2IBgiU5AZCRggGgI1kBryNKAb4heQ +HNIWoB3B+ZAesfigH6HbkCB2KyAhgb2QIlYNICNq2hAkNe8gJUq8ECYV0SAnKp4QJ/7toCkKgBAp3s+g +KupiECu+saAs036QLZ6ToC6zYJAvfnWgMJNCkDFnkiAycySQM0d0IDRTBpA1J1YgNjLokDcHOCA4HAUQ +OOcaIDn75xA6xvwgO9vJEDywGKA9u6sQPo/6oD+bjRBAb9ygQYSpkEJPvqBDZIuQRC+goEVEbZBF89Mg +Ry2KEEfTtSBJDWwQSbOXIErtThBLnLOgTNZqkE18laBOtkyQT1x3oFCWLpBRPFmgUnYQkFMcO6BUVfKQ +VPwdoFY11JBW5TogWB7xEFjFHCBZ/tMQWqT+IFvetRBchOAgXb6XEF5kwiBfnnkQYE3eoGGHlZBiLcCg +Y2d3kGQNoqBlR1mQZe2EoGcnO5BnzWagaQcdkGmtSKBq5v+Qa5ZlIGzQHBBtdkcgbq/+EG9WKSBwj+AQ +cTYLIHJvwhBzFe0gdE+kEHT/CaB2OMCQdt7roHgYopB4vs2gefiEkHqer6B72GaQfH6RoH24SJB+XnOg +f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA + + + + 283574831.24930698 + + 1 + + + + 290 + {320, 44} + + NO + NO + IBIPadFramework + 1 + + YES + + + + + Done + IBIPadFramework + 1 + + + IBIPadFramework + + + + + + 292 + {{20, 11}, {231, 23}} + + NO + YES + 7 + NO + IBIPadFramework + In amount of time + + LucidaGrande + 18 + 16 + + + 3 + MQA + + + + 3 + MAA + + 1 + 10 + 1 + + + {320, 260} + + + 1 + MCAwIDAgMAA + + NO + 1 + + 3 + + IBIPadFramework + + + + 269 + + YES + + + 301 + {328, 480} + + NO + YES + 2 + YES + IBIPadFramework + + NSImage + lightTexturedBackground.png + + + + + 274 + {328, 480} + + + YES + IBIPadFramework + YES + 0 + YES + 44 + 22 + 22 + + + {328, 480} + + + 3 + MQA + + 2 + + + IBIPadFramework + + + + + YES + + + alarmDatePickerContainerView + + + + 19 + + + + amountOfTimeLabel + + + + 20 + + + + toggleDatePicker: + + + + 21 + + + + alarmDatePicker + + + + 22 + + + + setAlarmDateInDatePicker: + + + 13 + + 23 + + + + view + + + + 30 + + + + tableView + + + + 48 + + + + dataSource + + + + 49 + + + + delegate + + + + 50 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 13 + + + YES + + + + + + Date picker view + + + 14 + + + YES + + + + + + 15 + + + + + 16 + + + + + 17 + + + YES + + + + + + 18 + + + + + 29 + + + YES + + + + + + + 34 + + + + + 47 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 13.IBEditorWindowLastContentRect + 13.IBPluginDependency + 14.IBPluginDependency + 15.IBPluginDependency + 16.IBPluginDependency + 17.IBPluginDependency + 18.IBPluginDependency + 29.IBEditorWindowLastContentRect + 29.IBPluginDependency + 47.IBPluginDependency + + + YES + AlarmSettingsViewController + UIResponder + {{331, 91}, {320, 260}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + {{312, 265}, {328, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 50 + + + + YES + + AlarmSettingsViewController + UIViewController + + YES + + YES + buttonSegmentTapped: + chooseMusic: + clearDigits: + enterDigit: + pushMapView: + pushVoiceControls: + setAlarmDateInDatePicker: + toggleDatePicker: + toggleKeypad: + + + YES + UIButton + id + id + id + id + id + id + id + id + + + + YES + + YES + buttonSegmentTapped: + chooseMusic: + clearDigits: + enterDigit: + pushMapView: + pushVoiceControls: + setAlarmDateInDatePicker: + toggleDatePicker: + toggleKeypad: + + + YES + + buttonSegmentTapped: + UIButton + + + chooseMusic: + id + + + clearDigits: + id + + + enterDigit: + id + + + pushMapView: + id + + + pushVoiceControls: + id + + + setAlarmDateInDatePicker: + id + + + toggleDatePicker: + id + + + toggleKeypad: + id + + + + + YES + + YES + alarmDatePicker + alarmDatePickerContainerView + amountOfTimeLabel + navigationBar + tableView + + + YES + UIDatePicker + UIView + UILabel + UINavigationBar + UITableView + + + + YES + + YES + alarmDatePicker + alarmDatePickerContainerView + amountOfTimeLabel + navigationBar + tableView + + + YES + + alarmDatePicker + UIDatePicker + + + alarmDatePickerContainerView + UIView + + + amountOfTimeLabel + UILabel + + + navigationBar + UINavigationBar + + + tableView + UITableView + + + + + IBProjectSource + Classes/AlarmSettingsViewController.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIBarButtonItem + UIBarItem + + IBFrameworkSource + UIKit.framework/Headers/UIBarButtonItem.h + + + + UIBarItem + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIBarItem.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIDatePicker + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIDatePicker.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UINavigationBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UINavigationBar.h + + + + UINavigationItem + NSObject + + + + UIResponder + NSObject + + + + UIScrollView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIScrollView.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UITableView + UIScrollView + + IBFrameworkSource + UIKit.framework/Headers/UITableView.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + MediaPlayer.framework/Headers/MPMoviePlayerViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBIPadFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + lightTexturedBackground.png + {320, 540} + + 117 + + diff --git a/AlarmSettingsView.xib b/AlarmSettingsView.xib new file mode 100644 index 0000000..ee64157 --- /dev/null +++ b/AlarmSettingsView.xib @@ -0,0 +1,865 @@ + + + + 784 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 123 + + + YES + + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 292 + + YES + + + 256 + {320, 480} + + NO + YES + YES + IBCocoaTouchFramework + + NSImage + lightTexturedBackground.png + + + + + 274 + {{0, 44}, {320, 416}} + + + 3 + MQA + + NO + YES + NO + IBCocoaTouchFramework + NO + NO + 0 + YES + 44 + 22 + 22 + + + {320, 460} + + + 3 + MQA + + 2 + + + YES + NO + IBCocoaTouchFramework + + + + 292 + + YES + + + 292 + {{0, 44}, {320, 216}} + + + NO + YES + YES + IBCocoaTouchFramework + 0 + 0 + 0 + + en_US + + + America/Los_Angeles + + VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ +y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ +5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g +8n/BkPNvwKD0X6OQ9U+ioPY/hZD3L4Sg+CiiEPkPZqD6CIQQ+viDIPvoZhD82GUg/chIEP64RyD/qCoQ +AJgpIAGIDBACeAsgA3EokARhJ6AFUQqQBkEJoAcw7JAHjUOgCRDOkAmtvyAK8LCQC+CvoAzZzRANwJGg +DrmvEA+priAQmZEQEYmQIBJ5cxATaXIgFFlVEBVJVCAWOTcQFyk2IBgiU5AZCRggGgI1kBryNKAb4heQ +HNIWoB3B+ZAesfigH6HbkCB2KyAhgb2QIlYNICNq2hAkNe8gJUq8ECYV0SAnKp4QJ/7toCkKgBAp3s+g +KupiECu+saAs036QLZ6ToC6zYJAvfnWgMJNCkDFnkiAycySQM0d0IDRTBpA1J1YgNjLokDcHOCA4HAUQ +OOcaIDn75xA6xvwgO9vJEDywGKA9u6sQPo/6oD+bjRBAb9ygQYSpkEJPvqBDZIuQRC+goEVEbZBF89Mg +Ry2KEEfTtSBJDWwQSbOXIErtThBLnLOgTNZqkE18laBOtkyQT1x3oFCWLpBRPFmgUnYQkFMcO6BUVfKQ +VPwdoFY11JBW5TogWB7xEFjFHCBZ/tMQWqT+IFvetRBchOAgXb6XEF5kwiBfnnkQYE3eoGGHlZBiLcCg +Y2d3kGQNoqBlR1mQZe2EoGcnO5BnzWagaQcdkGmtSKBq5v+Qa5ZlIGzQHBBtdkcgbq/+EG9WKSBwj+AQ +cTYLIHJvwhBzFe0gdE+kEHT/CaB2OMCQdt7roHgYopB4vs2gefiEkHqer6B72GaQfH6RoH24SJB+XnOg +f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA + + + + 283574831.24930698 + + 1 + + + + 290 + {320, 44} + + NO + NO + IBCocoaTouchFramework + 1 + + YES + + + + + Done + IBCocoaTouchFramework + 1 + + + IBCocoaTouchFramework + + + + + + 292 + {{20, 11}, {231, 23}} + + NO + YES + 7 + NO + IBCocoaTouchFramework + In amount of time + + LucidaGrande + 18 + 16 + + + + + 3 + MAA + + 1 + 10 + 1 + + + {320, 260} + + + 1 + MC4zOTc5NTkxODM3IDAuMzk3OTU5MTgzNyAwLjM5Nzk1OTE4MzcgMAA + + NO + 1 + + 3 + + IBCocoaTouchFramework + + + + + YES + + + dataSource + + + + 21 + + + + delegate + + + + 22 + + + + view + + + + 24 + + + + tableView + + + + 25 + + + + alarmDatePicker + + + + 31 + + + + alarmDatePickerContainerView + + + + 32 + + + + setAlarmDateInDatePicker: + + + 13 + + 33 + + + + toggleDatePicker: + + + + 39 + + + + amountOfTimeLabel + + + + 48 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 15 + + + YES + + + + + + + 16 + + + + + 18 + + + + + 26 + + + YES + + + + + + Date picker view + + + 27 + + + + + 47 + + + + + 36 + + + YES + + + + + + 37 + + + YES + + + + + + 38 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 15.IBEditorWindowLastContentRect + 15.IBPluginDependency + 18.IBPluginDependency + 26.IBEditorWindowLastContentRect + 26.IBPluginDependency + 27.IBPluginDependency + 36.IBPluginDependency + 37.IBPluginDependency + 38.IBPluginDependency + 47.IBPluginDependency + + + YES + AlarmSettingsViewController + UIResponder + {{616, 52}, {320, 460}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + {{305, 448}, {320, 260}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 50 + + + + YES + + AlarmSettingsViewController + UIViewController + + YES + + YES + buttonSegmentTapped: + chooseMusic: + clearDigits: + enterDigit: + pushMapView: + pushVoiceControls: + setAlarmDateInDatePicker: + toggleDatePicker: + toggleKeypad: + + + YES + UIButton + id + id + id + id + id + id + id + id + + + + YES + + YES + buttonSegmentTapped: + chooseMusic: + clearDigits: + enterDigit: + pushMapView: + pushVoiceControls: + setAlarmDateInDatePicker: + toggleDatePicker: + toggleKeypad: + + + YES + + buttonSegmentTapped: + UIButton + + + chooseMusic: + id + + + clearDigits: + id + + + enterDigit: + id + + + pushMapView: + id + + + pushVoiceControls: + id + + + setAlarmDateInDatePicker: + id + + + toggleDatePicker: + id + + + toggleKeypad: + id + + + + + YES + + YES + alarmDatePicker + alarmDatePickerContainerView + amountOfTimeLabel + navigationBar + tableView + + + YES + UIDatePicker + UIView + UILabel + UINavigationBar + UITableView + + + + YES + + YES + alarmDatePicker + alarmDatePickerContainerView + amountOfTimeLabel + navigationBar + tableView + + + YES + + alarmDatePicker + UIDatePicker + + + alarmDatePickerContainerView + UIView + + + amountOfTimeLabel + UILabel + + + navigationBar + UINavigationBar + + + tableView + UITableView + + + + + IBProjectSource + Classes/AlarmSettingsViewController.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIBarButtonItem + UIBarItem + + IBFrameworkSource + UIKit.framework/Headers/UIBarButtonItem.h + + + + UIBarItem + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIBarItem.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIDatePicker + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIDatePicker.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UINavigationBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UINavigationBar.h + + + + UINavigationItem + NSObject + + + + UIResponder + NSObject + + + + UIScrollView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIScrollView.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UITableView + UIScrollView + + IBFrameworkSource + UIKit.framework/Headers/UITableView.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + MediaPlayer.framework/Headers/MPMoviePlayerViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + lightTexturedBackground.png + {320, 540} + + 123 + + diff --git a/CADebugMacros.cpp b/CADebugMacros.cpp new file mode 100755 index 0000000..15139fb --- /dev/null +++ b/CADebugMacros.cpp @@ -0,0 +1,91 @@ +/* + + File: CADebugMacros.cpp +Abstract: Helper class for printing debug messages + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#include "CADebugMacros.h" +#include +#include +#if TARGET_API_MAC_OSX + #include +#endif + +#if DEBUG +#include + +void DebugPrint(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + vprintf(fmt, args); + va_end(args); +} +#endif // DEBUG + +#if TARGET_API_MAC_OSX +void LogError(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); +#if DEBUG + vprintf(fmt, args); +#endif + vsyslog(LOG_ERR, fmt, args); + va_end(args); +} + +void LogWarning(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); +#if DEBUG + vprintf(fmt, args); +#endif + vsyslog(LOG_WARNING, fmt, args); + va_end(args); +} +#endif diff --git a/CADebugMacros.h b/CADebugMacros.h new file mode 100755 index 0000000..605ec36 --- /dev/null +++ b/CADebugMacros.h @@ -0,0 +1,440 @@ +/* + + File: CADebugMacros.h +Abstract: Helper class for printing debug messages + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#if !defined(__CADebugMacros_h__) +#define __CADebugMacros_h__ + +//============================================================================= +// Includes +//============================================================================= + +#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) + #include +#else + #include "CoreAudioTypes.h" +#endif + +//============================================================================= +// CADebugMacros +//============================================================================= + +//#define CoreAudio_StopOnFailure 1 +//#define CoreAudio_TimeStampMessages 1 +//#define CoreAudio_ThreadStampMessages 1 +//#define CoreAudio_FlushDebugMessages 1 + +#if TARGET_RT_BIG_ENDIAN + #define CA4CCToCString(the4CC) { ((char*)&the4CC)[0], ((char*)&the4CC)[1], ((char*)&the4CC)[2], ((char*)&the4CC)[3], 0 } + #define CACopy4CCToCString(theCString, the4CC) { theCString[0] = ((char*)&the4CC)[0]; theCString[1] = ((char*)&the4CC)[1]; theCString[2] = ((char*)&the4CC)[2]; theCString[3] = ((char*)&the4CC)[3]; theCString[4] = 0; } +#else + #define CA4CCToCString(the4CC) { ((char*)&the4CC)[3], ((char*)&the4CC)[2], ((char*)&the4CC)[1], ((char*)&the4CC)[0], 0 } + #define CACopy4CCToCString(theCString, the4CC) { theCString[0] = ((char*)&the4CC)[3]; theCString[1] = ((char*)&the4CC)[2]; theCString[2] = ((char*)&the4CC)[1]; theCString[3] = ((char*)&the4CC)[0]; theCString[4] = 0; } +#endif + +#pragma mark Basic Definitions + +#if DEBUG || CoreAudio_Debug + + // can be used to break into debugger immediately, also see CADebugger + #define BusError() (*(long *)0 = 0) + + // basic debugging print routines + #if TARGET_OS_MAC && !TARGET_API_MAC_CARBON + extern void DebugStr(const unsigned char* debuggerMsg); + #define DebugMessage(msg) DebugStr("\p"msg) + #define DebugMessageN1(msg, N1) + #define DebugMessageN2(msg, N1, N2) + #define DebugMessageN3(msg, N1, N2, N3) + #else + #include "CADebugPrintf.h" + + #if (CoreAudio_FlushDebugMessages && !CoreAudio_UseSysLog) || defined(CoreAudio_UseSideFile) + #define FlushRtn ,fflush(DebugPrintfFile) + #else + #define FlushRtn + #endif + + #if CoreAudio_ThreadStampMessages + #include + #include "CAHostTimeBase.h" + #define DebugMessage(msg) DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: %s"DebugPrintfLineEnding, pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), msg) FlushRtn + #define DebugMessageN1(msg, N1) DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1) FlushRtn + #define DebugMessageN2(msg, N1, N2) DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2) FlushRtn + #define DebugMessageN3(msg, N1, N2, N3) DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3) FlushRtn + #define DebugMessageN4(msg, N1, N2, N3, N4) DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4) FlushRtn + #define DebugMessageN5(msg, N1, N2, N3, N4, N5) DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5) FlushRtn + #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6) DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6) FlushRtn + #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7) DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7) FlushRtn + #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8) DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn + #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn + #elif CoreAudio_TimeStampMessages + #include "CAHostTimeBase.h" + #define DebugMessage(msg) DebugPrintfRtn(DebugPrintfFileComma "%.4f: %s"DebugPrintfLineEnding, pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), msg) FlushRtn + #define DebugMessageN1(msg, N1) DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1) FlushRtn + #define DebugMessageN2(msg, N1, N2) DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2) FlushRtn + #define DebugMessageN3(msg, N1, N2, N3) DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3) FlushRtn + #define DebugMessageN4(msg, N1, N2, N3, N4) DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4) FlushRtn + #define DebugMessageN5(msg, N1, N2, N3, N4, N5) DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5) FlushRtn + #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6) DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6) FlushRtn + #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7) DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7) FlushRtn + #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8) DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn + #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFileComma "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn + #else + #define DebugMessage(msg) DebugPrintfRtn(DebugPrintfFileComma "%s"DebugPrintfLineEnding, msg) FlushRtn + #define DebugMessageN1(msg, N1) DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1) FlushRtn + #define DebugMessageN2(msg, N1, N2) DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2) FlushRtn + #define DebugMessageN3(msg, N1, N2, N3) DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3) FlushRtn + #define DebugMessageN4(msg, N1, N2, N3, N4) DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4) FlushRtn + #define DebugMessageN5(msg, N1, N2, N3, N4, N5) DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4, N5) FlushRtn + #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6) DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6) FlushRtn + #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7) DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6, N7) FlushRtn + #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8) DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn + #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFileComma msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn + #endif + #endif + void DebugPrint(const char *fmt, ...); // can be used like printf + #ifndef DEBUGPRINT + #define DEBUGPRINT(msg) DebugPrint msg // have to double-parenthesize arglist (see Debugging.h) + #endif + #if VERBOSE + #define vprint(msg) DEBUGPRINT(msg) + #else + #define vprint(msg) + #endif + + #if CoreAudio_StopOnFailure + #include "CADebugger.h" + #define STOP CADebuggerStop() + #else + #define STOP + #endif + +#else + #define DebugMessage(msg) + #define DebugMessageN1(msg, N1) + #define DebugMessageN2(msg, N1, N2) + #define DebugMessageN3(msg, N1, N2, N3) + #define DebugMessageN4(msg, N1, N2, N3, N4) + #define DebugMessageN5(msg, N1, N2, N3, N4, N5) + #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6) + #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7) + #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8) + #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) + #define DEBUGPRINT(msg) + #define vprint(msg) + #define STOP +#endif + +void LogError(const char *fmt, ...); // writes to syslog (and stderr if debugging) +void LogWarning(const char *fmt, ...); // writes to syslog (and stderr if debugging) + +#if DEBUG || CoreAudio_Debug + +#pragma mark Debug Macros + +#define Assert(inCondition, inMessage) \ + if(!(inCondition)) \ + { \ + DebugMessage(inMessage); \ + STOP; \ + } + +#define AssertNoError(inError, inMessage) \ + { \ + SInt32 __Err = (inError); \ + if(__Err != 0) \ + { \ + char __4CC[5] = CA4CCToCString(__Err); \ + DebugMessageN2(inMessage ", Error: %d (%s)", (int)__Err, __4CC); \ + STOP; \ + } \ + } + +#define AssertNoKernelError(inError, inMessage) \ + { \ + unsigned int __Err = (unsigned int)(inError); \ + if(__Err != 0) \ + { \ + DebugMessageN1(inMessage ", Error: 0x%X", __Err); \ + STOP; \ + } \ + } + +#define FailIf(inCondition, inHandler, inMessage) \ + if(inCondition) \ + { \ + DebugMessage(inMessage); \ + STOP; \ + goto inHandler; \ + } + +#define FailWithAction(inCondition, inAction, inHandler, inMessage) \ + if(inCondition) \ + { \ + DebugMessage(inMessage); \ + STOP; \ + { inAction; } \ + goto inHandler; \ + } + +#define FailIfNULL(inPointer, inAction, inHandler, inMessage) \ + if((inPointer) == NULL) \ + { \ + DebugMessage(inMessage); \ + STOP; \ + { inAction; } \ + goto inHandler; \ + } + +#define FailIfKernelError(inKernelError, inAction, inHandler, inMessage) \ + { \ + kern_return_t __Err = (inKernelError); \ + if(__Err != 0) \ + { \ + DebugMessageN1(inMessage ", Error: 0x%X", __Err); \ + STOP; \ + { inAction; } \ + goto inHandler; \ + } \ + } + +#define FailIfError(inError, inAction, inHandler, inMessage) \ + { \ + SInt32 __Err = (inError); \ + if(__Err != 0) \ + { \ + char __4CC[5] = CA4CCToCString(__Err); \ + DebugMessageN2(inMessage ", Error: %ld (%s)", __Err, __4CC); \ + STOP; \ + { inAction; } \ + goto inHandler; \ + } \ + } + +#if defined(__cplusplus) + +#define Throw(inException) STOP; throw (inException) + +#define ThrowIf(inCondition, inException, inMessage) \ + if(inCondition) \ + { \ + DebugMessage(inMessage); \ + Throw(inException); \ + } + +#define ThrowIfNULL(inPointer, inException, inMessage) \ + if((inPointer) == NULL) \ + { \ + DebugMessage(inMessage); \ + Throw(inException); \ + } + +#define ThrowIfKernelError(inKernelError, inException, inMessage) \ + { \ + kern_return_t __Err = (inKernelError); \ + if(__Err != 0) \ + { \ + DebugMessageN1(inMessage ", Error: 0x%X", __Err); \ + Throw(inException); \ + } \ + } + +#define ThrowIfError(inError, inException, inMessage) \ + { \ + SInt32 __Err = (inError); \ + if(__Err != 0) \ + { \ + char __4CC[5] = CA4CCToCString(__Err); \ + DebugMessageN2(inMessage ", Error: %d (%s)", (int)__Err, __4CC); \ + Throw(inException); \ + } \ + } + +#if TARGET_OS_WIN32 +#define ThrowIfWinError(inError, inException, inMessage) \ + { \ + HRESULT __Err = (inError); \ + if(FAILED(__Err)) \ + { \ + DebugMessageN2(inMessage ", Code: %d, Facility: 0x%X", HRESULT_CODE(__Err), HRESULT_FACILITY(__Err)); \ + Throw(inException); \ + } \ + } +#endif + +#define SubclassResponsibility(inMethodName, inException) \ + { \ + DebugMessage(inMethodName": Subclasses must implement this method"); \ + Throw(inException); \ + } + +#endif // defined(__cplusplus) + +#else + +#pragma mark Release Macros + +#define Assert(inCondition, inMessage) \ + if(!(inCondition)) \ + { \ + STOP; \ + } + +#define AssertNoError(inError, inMessage) \ + { \ + SInt32 __Err = (inError); \ + if(__Err != 0) \ + { \ + STOP; \ + } \ + } + +#define AssertNoKernelError(inError, inMessage) \ + { \ + unsigned int __Err = (unsigned int)(inError); \ + if(__Err != 0) \ + { \ + STOP; \ + } \ + } + +#define FailIf(inCondition, inHandler, inMessage) \ + if(inCondition) \ + { \ + STOP; \ + goto inHandler; \ + } + +#define FailWithAction(inCondition, inAction, inHandler, inMessage) \ + if(inCondition) \ + { \ + STOP; \ + { inAction; } \ + goto inHandler; \ + } + +#define FailIfNULL(inPointer, inAction, inHandler, inMessage) \ + if((inPointer) == NULL) \ + { \ + STOP; \ + { inAction; } \ + goto inHandler; \ + } + +#define FailIfKernelError(inKernelError, inAction, inHandler, inMessage) \ + if((inKernelError) != 0) \ + { \ + STOP; \ + { inAction; } \ + goto inHandler; \ + } + +#define FailIfError(inError, inAction, inHandler, inMessage) \ + if((inError) != 0) \ + { \ + STOP; \ + { inAction; } \ + goto inHandler; \ + } + +#if defined(__cplusplus) + +#define Throw(inException) STOP; throw (inException) + +#define ThrowIf(inCondition, inException, inMessage) \ + if(inCondition) \ + { \ + Throw(inException); \ + } + +#define ThrowIfNULL(inPointer, inException, inMessage) \ + if((inPointer) == NULL) \ + { \ + Throw(inException); \ + } + +#define ThrowIfKernelError(inKernelError, inException, inMessage) \ + { \ + kern_return_t __Err = (inKernelError); \ + if(__Err != 0) \ + { \ + Throw(inException); \ + } \ + } + +#define ThrowIfError(inError, inException, inMessage) \ + { \ + SInt32 __Err = (inError); \ + if(__Err != 0) \ + { \ + Throw(inException); \ + } \ + } + +#if TARGET_OS_WIN32 +#define ThrowIfWinError(inError, inException, inMessage) \ + { \ + HRESULT __Err = (inError); \ + if(FAILED(__Err)) \ + { \ + Throw(inException); \ + } \ + } +#endif + +#define SubclassResponsibility(inMethodName, inException) \ + { \ + Throw(inException); \ + } + +#endif // defined(__cplusplus) + +#endif // DEBUG || CoreAudio_Debug + +#endif diff --git a/CAMath.h b/CAMath.h new file mode 100755 index 0000000..f32cff3 --- /dev/null +++ b/CAMath.h @@ -0,0 +1,71 @@ +/* + + File: CAMath.h +Abstract: Helper class for various math functions + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#ifndef __CAMath_h__ +#define __CAMath_h__ + +#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) + #include +#else + #include +#endif + +inline bool fiszero(Float64 f) { return (f == 0.); } +inline bool fiszero(Float32 f) { return (f == 0.f); } + +inline bool fnonzero(Float64 f) { return !fiszero(f); } +inline bool fnonzero(Float32 f) { return !fiszero(f); } + +inline bool fequal(const Float64 &a, const Float64 &b) { return a == b; } +inline bool fequal(const Float32 &a, const Float32 &b) { return a == b; } + +inline bool fnotequal(const Float64 &a, const Float64 &b) { return !fequal(a, b); } +inline bool fnotequal(const Float32 &a, const Float32 &b) { return !fequal(a, b); } + +#endif // __CAMath_h__ diff --git a/CAStreamBasicDescription.cpp b/CAStreamBasicDescription.cpp new file mode 100755 index 0000000..19e4721 --- /dev/null +++ b/CAStreamBasicDescription.cpp @@ -0,0 +1,552 @@ +/* + + File: CAStreamBasicDescription.cpp +Abstract: Helper class for audio stream descriptions + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#include "CAStreamBasicDescription.h" +#include "CAMath.h" + +#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) + #include +#else + #include +#endif + +#if TARGET_OS_WIN32 + #include +#endif + +#pragma mark This file needs to compile on earlier versions of the OS, so please keep that in mind when editing it + +const AudioStreamBasicDescription CAStreamBasicDescription::sEmpty = { 0.0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +CAStreamBasicDescription::CAStreamBasicDescription(double inSampleRate, UInt32 inFormatID, + UInt32 inBytesPerPacket, UInt32 inFramesPerPacket, + UInt32 inBytesPerFrame, UInt32 inChannelsPerFrame, + UInt32 inBitsPerChannel, UInt32 inFormatFlags) +{ + mSampleRate = inSampleRate; + mFormatID = inFormatID; + mBytesPerPacket = inBytesPerPacket; + mFramesPerPacket = inFramesPerPacket; + mBytesPerFrame = inBytesPerFrame; + mChannelsPerFrame = inChannelsPerFrame; + mBitsPerChannel = inBitsPerChannel; + mFormatFlags = inFormatFlags; + mReserved = 0; +} + +char *CAStreamBasicDescription::AsString(char *buf, size_t bufsize) const +{ + char *theBuffer = buf; + int nc; + char formatID[5]; + *(UInt32 *)formatID = CFSwapInt32HostToBig(mFormatID); + formatID[4] = '\0'; + nc = snprintf(buf, bufsize, "%2d ch, %6.0f Hz, '%-4.4s' (0x%08X) ", (int)NumberChannels(), mSampleRate, formatID, (int)mFormatFlags); + buf += nc; bufsize -= nc; + if (mFormatID == kAudioFormatLinearPCM) { + bool isInt = !(mFormatFlags & kLinearPCMFormatFlagIsFloat); + int wordSize = SampleWordSize(); + const char *endian = (wordSize > 1) ? + ((mFormatFlags & kLinearPCMFormatFlagIsBigEndian) ? " big-endian" : " little-endian" ) : ""; + const char *sign = isInt ? + ((mFormatFlags & kLinearPCMFormatFlagIsSignedInteger) ? " signed" : " unsigned") : ""; + const char *floatInt = isInt ? "integer" : "float"; + char packed[32]; + if (wordSize > 0 && PackednessIsSignificant()) { + if (mFormatFlags & kLinearPCMFormatFlagIsPacked) + sprintf(packed, "packed in %d bytes", wordSize); + else + sprintf(packed, "unpacked in %d bytes", wordSize); + } else + packed[0] = '\0'; + const char *align = (wordSize > 0 && AlignmentIsSignificant()) ? + ((mFormatFlags & kLinearPCMFormatFlagIsAlignedHigh) ? " high-aligned" : " low-aligned") : ""; + const char *deinter = (mFormatFlags & kAudioFormatFlagIsNonInterleaved) ? ", deinterleaved" : ""; + const char *commaSpace = (packed[0]!='\0') || (align[0]!='\0') ? ", " : ""; + char bitdepth[20]; + +#if CA_PREFER_FIXED_POINT + int fracbits = (mFormatFlags & kLinearPCMFormatFlagsSampleFractionMask) >> kLinearPCMFormatFlagsSampleFractionShift; + if (fracbits > 0) + sprintf(bitdepth, "%d.%d", (int)mBitsPerChannel - fracbits, fracbits); + else +#endif + sprintf(bitdepth, "%d", (int)mBitsPerChannel); + + nc = snprintf(buf, bufsize, "%s-bit%s%s %s%s%s%s%s", + bitdepth, endian, sign, floatInt, + commaSpace, packed, align, deinter); + //buf += nc; bufsize -= nc; + } else if (mFormatID == 'alac') { // kAudioFormatAppleLossless + int sourceBits = 0; + switch (mFormatFlags) + { + case 1: // kAppleLosslessFormatFlag_16BitSourceData + sourceBits = 16; + break; + case 2: // kAppleLosslessFormatFlag_20BitSourceData + sourceBits = 20; + break; + case 3: // kAppleLosslessFormatFlag_24BitSourceData + sourceBits = 24; + break; + case 4: // kAppleLosslessFormatFlag_32BitSourceData + sourceBits = 32; + break; + } + if (sourceBits) + nc = snprintf(buf, bufsize, "from %d-bit source, ", sourceBits); + else + nc = snprintf(buf, bufsize, "from UNKNOWN source bit depth, "); + buf += nc; bufsize -= nc; + nc = snprintf(buf, bufsize, "%d frames/packet", (int)mFramesPerPacket); + //buf += nc; bufsize -= nc; + } + else + nc = snprintf(buf, bufsize, "%d bits/channel, %d bytes/packet, %d frames/packet, %d bytes/frame", + (int)mBitsPerChannel, (int)mBytesPerPacket, (int)mFramesPerPacket, (int)mBytesPerFrame); + return theBuffer; +} + +void CAStreamBasicDescription::NormalizeLinearPCMFormat(AudioStreamBasicDescription& ioDescription) +{ + // the only thing that changes is to make mixable linear PCM into the canonical linear PCM format + if((ioDescription.mFormatID == kAudioFormatLinearPCM) && ((ioDescription.mFormatFlags & kIsNonMixableFlag) == 0)) + { + // the canonical linear PCM format + ioDescription.mFormatFlags = kAudioFormatFlagsCanonical; + ioDescription.mBytesPerPacket = sizeof(AudioSampleType) * ioDescription.mChannelsPerFrame; + ioDescription.mFramesPerPacket = 1; + ioDescription.mBytesPerFrame = sizeof(AudioSampleType) * ioDescription.mChannelsPerFrame; + ioDescription.mBitsPerChannel = 8 * sizeof(AudioSampleType); + } +} + +void CAStreamBasicDescription::ResetFormat(AudioStreamBasicDescription& ioDescription) +{ + ioDescription.mSampleRate = 0; + ioDescription.mFormatID = 0; + ioDescription.mBytesPerPacket = 0; + ioDescription.mFramesPerPacket = 0; + ioDescription.mBytesPerFrame = 0; + ioDescription.mChannelsPerFrame = 0; + ioDescription.mBitsPerChannel = 0; + ioDescription.mFormatFlags = 0; +} + +void CAStreamBasicDescription::FillOutFormat(AudioStreamBasicDescription& ioDescription, const AudioStreamBasicDescription& inTemplateDescription) +{ + if(fiszero(ioDescription.mSampleRate)) + { + ioDescription.mSampleRate = inTemplateDescription.mSampleRate; + } + if(ioDescription.mFormatID == 0) + { + ioDescription.mFormatID = inTemplateDescription.mFormatID; + } + if(ioDescription.mFormatFlags == 0) + { + ioDescription.mFormatFlags = inTemplateDescription.mFormatFlags; + } + if(ioDescription.mBytesPerPacket == 0) + { + ioDescription.mBytesPerPacket = inTemplateDescription.mBytesPerPacket; + } + if(ioDescription.mFramesPerPacket == 0) + { + ioDescription.mFramesPerPacket = inTemplateDescription.mFramesPerPacket; + } + if(ioDescription.mBytesPerFrame == 0) + { + ioDescription.mBytesPerFrame = inTemplateDescription.mBytesPerFrame; + } + if(ioDescription.mChannelsPerFrame == 0) + { + ioDescription.mChannelsPerFrame = inTemplateDescription.mChannelsPerFrame; + } + if(ioDescription.mBitsPerChannel == 0) + { + ioDescription.mBitsPerChannel = inTemplateDescription.mBitsPerChannel; + } +} + +void CAStreamBasicDescription::GetSimpleName(const AudioStreamBasicDescription& inDescription, char* outName, bool inAbbreviate) +{ + switch(inDescription.mFormatID) + { + case kAudioFormatLinearPCM: + { + const char* theEndianString = NULL; + if((inDescription.mFormatFlags & kAudioFormatFlagIsBigEndian) != 0) + { + #if TARGET_RT_LITTLE_ENDIAN + theEndianString = "Big Endian"; + #endif + } + else + { + #if TARGET_RT_BIG_ENDIAN + theEndianString = "Little Endian"; + #endif + } + + const char* theKindString = NULL; + if((inDescription.mFormatFlags & kAudioFormatFlagIsFloat) != 0) + { + theKindString = (inAbbreviate ? "Float" : "Floating Point"); + } + else if((inDescription.mFormatFlags & kAudioFormatFlagIsSignedInteger) != 0) + { + theKindString = (inAbbreviate ? "SInt" : "Signed Integer"); + } + else + { + theKindString = (inAbbreviate ? "UInt" : "Unsigned Integer"); + } + + const char* thePackingString = NULL; + if((inDescription.mFormatFlags & kAudioFormatFlagIsPacked) == 0) + { + if((inDescription.mFormatFlags & kAudioFormatFlagIsAlignedHigh) != 0) + { + thePackingString = "High"; + } + else + { + thePackingString = "Low"; + } + } + + const char* theMixabilityString = NULL; + if((inDescription.mFormatFlags & kIsNonMixableFlag) == 0) + { + theMixabilityString = "Mixable"; + } + else + { + theMixabilityString = "Unmixable"; + } + + if(inAbbreviate) + { + if(theEndianString != NULL) + { + if(thePackingString != NULL) + { + sprintf(outName, "%s %d Ch %s %s %s%d/%s%d", theMixabilityString, (int)inDescription.mChannelsPerFrame, theEndianString, thePackingString, theKindString, (int)inDescription.mBitsPerChannel, theKindString, (int)(inDescription.mBytesPerFrame / inDescription.mChannelsPerFrame) * 8); + } + else + { + sprintf(outName, "%s %d Ch %s %s%d", theMixabilityString, (int)inDescription.mChannelsPerFrame, theEndianString, theKindString, (int)inDescription.mBitsPerChannel); + } + } + else + { + if(thePackingString != NULL) + { + sprintf(outName, "%s %d Ch %s %s%d/%s%d", theMixabilityString, (int)inDescription.mChannelsPerFrame, thePackingString, theKindString, (int)inDescription.mBitsPerChannel, theKindString, (int)((inDescription.mBytesPerFrame / inDescription.mChannelsPerFrame) * 8)); + } + else + { + sprintf(outName, "%s %d Ch %s%d", theMixabilityString, (int)inDescription.mChannelsPerFrame, theKindString, (int)inDescription.mBitsPerChannel); + } + } + } + else + { + if(theEndianString != NULL) + { + if(thePackingString != NULL) + { + sprintf(outName, "%s %d Channel %d Bit %s %s Aligned %s in %d Bits", theMixabilityString, (int)inDescription.mChannelsPerFrame, (int)inDescription.mBitsPerChannel, theEndianString, theKindString, thePackingString, (int)(inDescription.mBytesPerFrame / inDescription.mChannelsPerFrame) * 8); + } + else + { + sprintf(outName, "%s %d Channel %d Bit %s %s", theMixabilityString, (int)inDescription.mChannelsPerFrame, (int)inDescription.mBitsPerChannel, theEndianString, theKindString); + } + } + else + { + if(thePackingString != NULL) + { + sprintf(outName, "%s %d Channel %d Bit %s Aligned %s in %d Bits", theMixabilityString, (int)inDescription.mChannelsPerFrame, (int)inDescription.mBitsPerChannel, theKindString, thePackingString, (int)(inDescription.mBytesPerFrame / inDescription.mChannelsPerFrame) * 8); + } + else + { + sprintf(outName, "%s %d Channel %d Bit %s", theMixabilityString, (int)inDescription.mChannelsPerFrame, (int)inDescription.mBitsPerChannel, theKindString); + } + } + } + } + break; + + case kAudioFormatAC3: + strcpy(outName, "AC-3"); + break; + + case kAudioFormat60958AC3: + strcpy(outName, "AC-3 for SPDIF"); + break; + + default: + CACopy4CCToCString(outName, inDescription.mFormatID); + break; + }; +} + +#if CoreAudio_Debug +#include "CALogMacros.h" + +void CAStreamBasicDescription::PrintToLog(const AudioStreamBasicDescription& inDesc) +{ + PrintFloat (" Sample Rate: ", inDesc.mSampleRate); + Print4CharCode (" Format ID: ", inDesc.mFormatID); + PrintHex (" Format Flags: ", inDesc.mFormatFlags); + PrintInt (" Bytes per Packet: ", inDesc.mBytesPerPacket); + PrintInt (" Frames per Packet: ", inDesc.mFramesPerPacket); + PrintInt (" Bytes per Frame: ", inDesc.mBytesPerFrame); + PrintInt (" Channels per Frame: ", inDesc.mChannelsPerFrame); + PrintInt (" Bits per Channel: ", inDesc.mBitsPerChannel); +} +#endif + +bool operator<(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) +{ + bool theAnswer = false; + bool isDone = false; + + // note that if either side is 0, that field is skipped + + // format ID is the first order sort + if((!isDone) && ((x.mFormatID != 0) && (y.mFormatID != 0))) + { + if(x.mFormatID != y.mFormatID) + { + // formats are sorted numerically except that linear + // PCM is always first + if(x.mFormatID == kAudioFormatLinearPCM) + { + theAnswer = true; + } + else if(y.mFormatID == kAudioFormatLinearPCM) + { + theAnswer = false; + } + else + { + theAnswer = x.mFormatID < y.mFormatID; + } + isDone = true; + } + } + + + // mixable is always better than non-mixable for linear PCM and should be the second order sort item + if((!isDone) && ((x.mFormatID == kAudioFormatLinearPCM) && (y.mFormatID == kAudioFormatLinearPCM))) + { + if(((x.mFormatFlags & kIsNonMixableFlag) == 0) && ((y.mFormatFlags & kIsNonMixableFlag) != 0)) + { + theAnswer = true; + isDone = true; + } + else if(((x.mFormatFlags & kIsNonMixableFlag) != 0) && ((y.mFormatFlags & kIsNonMixableFlag) == 0)) + { + theAnswer = false; + isDone = true; + } + } + + // floating point vs integer for linear PCM only + if((!isDone) && ((x.mFormatID == kAudioFormatLinearPCM) && (y.mFormatID == kAudioFormatLinearPCM))) + { + if((x.mFormatFlags & kAudioFormatFlagIsFloat) != (y.mFormatFlags & kAudioFormatFlagIsFloat)) + { + // floating point is better than integer + theAnswer = y.mFormatFlags & kAudioFormatFlagIsFloat; + isDone = true; + } + } + + // bit depth + if((!isDone) && ((x.mBitsPerChannel != 0) && (y.mBitsPerChannel != 0))) + { + if(x.mBitsPerChannel != y.mBitsPerChannel) + { + // deeper bit depths are higher quality + theAnswer = x.mBitsPerChannel < y.mBitsPerChannel; + isDone = true; + } + } + + // sample rate + if((!isDone) && fnonzero(x.mSampleRate) && fnonzero(y.mSampleRate)) + { + if(fnotequal(x.mSampleRate, y.mSampleRate)) + { + // higher sample rates are higher quality + theAnswer = x.mSampleRate < y.mSampleRate; + isDone = true; + } + } + + // number of channels + if((!isDone) && ((x.mChannelsPerFrame != 0) && (y.mChannelsPerFrame != 0))) + { + if(x.mChannelsPerFrame != y.mChannelsPerFrame) + { + // more channels is higher quality + theAnswer = x.mChannelsPerFrame < y.mChannelsPerFrame; + isDone = true; + } + } + + return theAnswer; +} + +static bool MatchFormatFlags(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) +{ + UInt32 xFlags = x.mFormatFlags; + UInt32 yFlags = y.mFormatFlags; + + // match wildcards + if (x.mFormatID == 0 || y.mFormatID == 0 || xFlags == 0 || yFlags == 0) + return true; + + if (x.mFormatID == kAudioFormatLinearPCM) + { + // knock off the all clear flag + xFlags = xFlags & ~kAudioFormatFlagsAreAllClear; + yFlags = yFlags & ~kAudioFormatFlagsAreAllClear; + + // if both kAudioFormatFlagIsPacked bits are set, then we don't care about the kAudioFormatFlagIsAlignedHigh bit. + if (xFlags & yFlags & kAudioFormatFlagIsPacked) { + xFlags = xFlags & ~kAudioFormatFlagIsAlignedHigh; + yFlags = yFlags & ~kAudioFormatFlagIsAlignedHigh; + } + + // if both kAudioFormatFlagIsFloat bits are set, then we don't care about the kAudioFormatFlagIsSignedInteger bit. + if (xFlags & yFlags & kAudioFormatFlagIsFloat) { + xFlags = xFlags & ~kAudioFormatFlagIsSignedInteger; + yFlags = yFlags & ~kAudioFormatFlagIsSignedInteger; + } + + // if the bit depth is 8 bits or less and the format is packed, we don't care about endianness + if((x.mBitsPerChannel <= 8) && ((xFlags & kAudioFormatFlagIsPacked) == kAudioFormatFlagIsPacked)) + { + xFlags = xFlags & ~kAudioFormatFlagIsBigEndian; + } + if((y.mBitsPerChannel <= 8) && ((yFlags & kAudioFormatFlagIsPacked) == kAudioFormatFlagIsPacked)) + { + yFlags = yFlags & ~kAudioFormatFlagIsBigEndian; + } + + // if the number of channels is 0 or 1, we don't care about non-interleavedness + if (x.mChannelsPerFrame <= 1 && y.mChannelsPerFrame <= 1) { + xFlags &= ~kLinearPCMFormatFlagIsNonInterleaved; + yFlags &= ~kLinearPCMFormatFlagIsNonInterleaved; + } + } + return xFlags == yFlags; +} + +bool operator==(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) +{ + // the semantics for equality are: + // 1) Values must match exactly + // 2) wildcard's are ignored in the comparison + +#define MATCH(name) ((x.name) == 0 || (y.name) == 0 || (x.name) == (y.name)) + + return + // check the sample rate + (fiszero(x.mSampleRate) || fiszero(y.mSampleRate) || fequal(x.mSampleRate, y.mSampleRate)) + + // check the format ids + && MATCH(mFormatID) + + // check the format flags + && MatchFormatFlags(x, y) + + // check the bytes per packet + && MATCH(mBytesPerPacket) + + // check the frames per packet + && MATCH(mFramesPerPacket) + + // check the bytes per frame + && MATCH(mBytesPerFrame) + + // check the channels per frame + && MATCH(mChannelsPerFrame) + + // check the channels per frame + && MATCH(mBitsPerChannel) ; +} + +bool CAStreamBasicDescription::IsEqual(const AudioStreamBasicDescription &other, bool interpretingWildcards) const +{ + if (interpretingWildcards) + return *this == other; + return memcmp(this, &other, offsetof(AudioStreamBasicDescription, mReserved)) == 0; +} + +bool SanityCheck(const AudioStreamBasicDescription& x) +{ + // This function returns false if there are sufficiently insane values in any field. + // It is very conservative so even some very unlikely values will pass. + // This is just meant to catch the case where the data from a file is corrupted. + + return + (x.mSampleRate >= 0.) + && (x.mBytesPerPacket < 1000000) + && (x.mFramesPerPacket < 1000000) + && (x.mBytesPerFrame < 1000000) + && (x.mChannelsPerFrame <= 1024) + && (x.mBitsPerChannel <= 1024); +} diff --git a/CAStreamBasicDescription.h b/CAStreamBasicDescription.h new file mode 100755 index 0000000..9c6cdc1 --- /dev/null +++ b/CAStreamBasicDescription.h @@ -0,0 +1,310 @@ +/* + + File: CAStreamBasicDescription.h +Abstract: Helper class for audio stream descriptions + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + + +#ifndef __CAStreamBasicDescription_h__ +#define __CAStreamBasicDescription_h__ + +#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) + #include + #include +#else + #include "CoreAudioTypes.h" + #include "CoreFoundation.h" +#endif + +#include "CADebugMacros.h" +#include // for memset, memcpy +#include // for FILE * + +#pragma mark This file needs to compile on more earlier versions of the OS, so please keep that in mind when editing it + +// define Leopard specific symbols for backward compatibility if applicable +#if COREAUDIOTYPES_VERSION < 1050 +typedef Float32 AudioSampleType; +enum { kAudioFormatFlagsCanonical = kAudioFormatFlagIsFloat | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked }; +#endif +#if COREAUDIOTYPES_VERSION < 1051 +typedef Float32 AudioUnitSampleType; +#endif + +// define the IsMixable format flag for all versions of the system +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3) + enum { kIsNonMixableFlag = kAudioFormatFlagIsNonMixable }; +#else + enum { kIsNonMixableFlag = (1L << 6) }; +#endif + +//============================================================================= +// CAStreamBasicDescription +// +// This is a wrapper class for the AudioStreamBasicDescription struct. +// It adds a number of convenience routines, but otherwise adds nothing +// to the footprint of the original struct. +//============================================================================= +class CAStreamBasicDescription : + public AudioStreamBasicDescription +{ + +// Constants +public: + static const AudioStreamBasicDescription sEmpty; + +// Construction/Destruction +public: + CAStreamBasicDescription() { memset (this, 0, sizeof(AudioStreamBasicDescription)); } + + CAStreamBasicDescription(const AudioStreamBasicDescription &desc) + { + SetFrom(desc); + } + + CAStreamBasicDescription( double inSampleRate, UInt32 inFormatID, + UInt32 inBytesPerPacket, UInt32 inFramesPerPacket, + UInt32 inBytesPerFrame, UInt32 inChannelsPerFrame, + UInt32 inBitsPerChannel, UInt32 inFormatFlags); + +// Assignment + CAStreamBasicDescription& operator=(const AudioStreamBasicDescription& v) { SetFrom(v); return *this; } + + void SetFrom(const AudioStreamBasicDescription &desc) + { + memcpy(this, &desc, sizeof(AudioStreamBasicDescription)); + } + + // _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + // + // interrogation + + bool IsPCM() const { return mFormatID == kAudioFormatLinearPCM; } + + bool PackednessIsSignificant() const + { + Assert(IsPCM(), "PackednessIsSignificant only applies for PCM"); + return (SampleWordSize() << 3) != mBitsPerChannel; + } + + bool AlignmentIsSignificant() const + { + return PackednessIsSignificant() || (mBitsPerChannel & 7) != 0; + } + + bool IsInterleaved() const + { + return !IsPCM() || !(mFormatFlags & kAudioFormatFlagIsNonInterleaved); + } + + // for sanity with interleaved/deinterleaved possibilities, never access mChannelsPerFrame, use these: + UInt32 NumberInterleavedChannels() const { return IsInterleaved() ? mChannelsPerFrame : 1; } + UInt32 NumberChannelStreams() const { return IsInterleaved() ? 1 : mChannelsPerFrame; } + UInt32 NumberChannels() const { return mChannelsPerFrame; } + UInt32 SampleWordSize() const { + return (mBytesPerFrame > 0 && NumberInterleavedChannels()) ? mBytesPerFrame / NumberInterleavedChannels() : 0; + } + + UInt32 FramesToBytes(UInt32 nframes) const { return nframes * mBytesPerFrame; } + UInt32 BytesToFrames(UInt32 nbytes) const { + Assert(mBytesPerFrame > 0, "bytesPerFrame must be > 0 in BytesToFrames"); + return nbytes / mBytesPerFrame; + } + + bool SameChannelsAndInterleaving(const CAStreamBasicDescription &a) const + { + return this->NumberChannels() == a.NumberChannels() && this->IsInterleaved() == a.IsInterleaved(); + } + + // _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + // + // manipulation + + void SetCanonical(UInt32 nChannels, bool interleaved) + // note: leaves sample rate untouched + { + mFormatID = kAudioFormatLinearPCM; +#if CA_ENV_MACOSX + int sampleSize = sizeof(Float32); + mFormatFlags = kAudioFormatFlagsNativeFloatPacked; +#else + int sampleSize = sizeof(AudioSampleType); + mFormatFlags = kAudioFormatFlagsCanonical; +#endif + mBitsPerChannel = 8 * sampleSize; + mChannelsPerFrame = nChannels; + mFramesPerPacket = 1; + if (interleaved) + mBytesPerPacket = mBytesPerFrame = nChannels * sampleSize; + else { + mBytesPerPacket = mBytesPerFrame = sampleSize; + mFormatFlags |= kAudioFormatFlagIsNonInterleaved; + } + } + + bool IsCanonical() const + { + if (mFormatID != kAudioFormatLinearPCM) return false; + UInt32 reqFormatFlags; +#if (COREAUDIOTYPES_VERSION <= 1050) + UInt32 flagsMask = (kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsBigEndian | kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked | kLinearPCMFormatFlagIsAlignedHigh); +#else + UInt32 flagsMask = (kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsBigEndian | kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked | kLinearPCMFormatFlagIsAlignedHigh | kLinearPCMFormatFlagsSampleFractionMask); +#endif + bool interleaved = (mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0; +#if CA_ENV_MACOSX + unsigned sampleSize = sizeof(Float32); + reqFormatFlags = kAudioFormatFlagsNativeFloatPacked; +#else + unsigned sampleSize = sizeof(AudioSampleType); + reqFormatFlags = kAudioFormatFlagsCanonical; +#endif + UInt32 reqFrameSize = interleaved ? (mChannelsPerFrame * sampleSize) : sampleSize; + + return ((mFormatFlags & flagsMask) == reqFormatFlags + && mBitsPerChannel == 8 * sampleSize + && mFramesPerPacket == 1 + && mBytesPerFrame == reqFrameSize + && mBytesPerPacket == reqFrameSize); + } + + void SetAUCanonical(UInt32 nChannels, bool interleaved) + { + mFormatID = kAudioFormatLinearPCM; +#if CA_PREFER_FIXED_POINT + mFormatFlags = kAudioFormatFlagsCanonical | (kAudioUnitSampleFractionBits << kLinearPCMFormatFlagsSampleFractionShift); +#else + mFormatFlags = kAudioFormatFlagsCanonical; +#endif + mChannelsPerFrame = nChannels; + mFramesPerPacket = 1; + mBitsPerChannel = 8 * sizeof(AudioUnitSampleType); + if (interleaved) + mBytesPerPacket = mBytesPerFrame = nChannels * sizeof(AudioUnitSampleType); + else { + mBytesPerPacket = mBytesPerFrame = sizeof(AudioUnitSampleType); + mFormatFlags |= kAudioFormatFlagIsNonInterleaved; + } + } + + void ChangeNumberChannels(UInt32 nChannels, bool interleaved) + // alter an existing format + { + Assert(IsPCM(), "ChangeNumberChannels only works for PCM formats"); + UInt32 wordSize = SampleWordSize(); // get this before changing ANYTHING + if (wordSize == 0) + wordSize = (mBitsPerChannel + 7) / 8; + mChannelsPerFrame = nChannels; + mFramesPerPacket = 1; + if (interleaved) { + mBytesPerPacket = mBytesPerFrame = nChannels * wordSize; + mFormatFlags &= ~kAudioFormatFlagIsNonInterleaved; + } else { + mBytesPerPacket = mBytesPerFrame = wordSize; + mFormatFlags |= kAudioFormatFlagIsNonInterleaved; + } + } + + // _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + // + // other + + bool IsEqual(const AudioStreamBasicDescription &other, bool interpretingWildcards=true) const; + + void Print() const { + Print (stdout); + } + + void Print(FILE* file) const { + PrintFormat (file, "", "AudioStreamBasicDescription:"); + } + + void PrintFormat(FILE *f, const char *indent, const char *name) const { + char buf[256]; + fprintf(f, "%s%s %s\n", indent, name, AsString(buf, sizeof(buf))); + } + + void PrintFormat2(FILE *f, const char *indent, const char *name) const { // no trailing newline + char buf[256]; + fprintf(f, "%s%s %s", indent, name, AsString(buf, sizeof(buf))); + } + + char * AsString(char *buf, size_t bufsize) const; + + static void Print (const AudioStreamBasicDescription &inDesc) + { + CAStreamBasicDescription desc(inDesc); + desc.Print (); + } + + OSStatus Save(CFPropertyListRef *outData) const; + + OSStatus Restore(CFPropertyListRef &inData); + +// Operations + static bool IsMixable(const AudioStreamBasicDescription& inDescription) { return (inDescription.mFormatID == kAudioFormatLinearPCM) && ((inDescription.mFormatFlags & kIsNonMixableFlag) == 0); } + static void NormalizeLinearPCMFormat(AudioStreamBasicDescription& ioDescription); + static void ResetFormat(AudioStreamBasicDescription& ioDescription); + static void FillOutFormat(AudioStreamBasicDescription& ioDescription, const AudioStreamBasicDescription& inTemplateDescription); + static void GetSimpleName(const AudioStreamBasicDescription& inDescription, char* outName, bool inAbbreviate); +#if CoreAudio_Debug + static void PrintToLog(const AudioStreamBasicDescription& inDesc); +#endif +}; + +bool operator<(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y); +bool operator==(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y); +#if TARGET_OS_MAC || (TARGET_OS_WIN32 && (_MSC_VER > 600)) +inline bool operator!=(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return !(x == y); } +inline bool operator<=(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return (x < y) || (x == y); } +inline bool operator>=(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return !(x < y); } +inline bool operator>(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return !((x < y) || (x == y)); } +#endif + +bool SanityCheck(const AudioStreamBasicDescription& x); + + +#endif // __CAStreamBasicDescription_h__ diff --git a/CAXException.cpp b/CAXException.cpp new file mode 100755 index 0000000..efeaab3 --- /dev/null +++ b/CAXException.cpp @@ -0,0 +1,53 @@ +/* + + File: CAXException.cpp +Abstract: Helper class for exception handling + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + + +#include "CAXException.h" + +CAXException::WarningHandler CAXException::sWarningHandler = NULL; diff --git a/CAXException.h b/CAXException.h new file mode 100755 index 0000000..d8d6750 --- /dev/null +++ b/CAXException.h @@ -0,0 +1,216 @@ +/* + + File: CAXException.h +Abstract: Helper class for exception handling + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + + +#ifndef __CAXException_h__ +#define __CAXException_h__ + +#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) + #include +#else + #include + #include +#endif +#include "CADebugMacros.h" +#include +#include +#include + +class CAX4CCString { +public: + CAX4CCString(OSStatus error) { + // see if it appears to be a 4-char-code + char *str = mStr; + *(UInt32 *)(str + 1) = CFSwapInt32HostToBig(error); + if (isprint(str[1]) && isprint(str[2]) && isprint(str[3]) && isprint(str[4])) { + str[0] = str[5] = '\''; + str[6] = '\0'; + } else if (error > -200000 && error < 200000) + // no, format it as an integer + sprintf(str, "%d", (int)error); + else + sprintf(str, "0x%x", (int)error); + } + const char *get() const { return mStr; } + operator const char *() const { return mStr; } +private: + char mStr[16]; +}; + +// An extended exception class that includes the name of the failed operation +class CAXException { +public: + CAXException(const char *operation, OSStatus err) : + mError(err) + { + if (operation == NULL) + mOperation[0] = '\0'; + else if (strlen(operation) >= sizeof(mOperation)) { + memcpy(mOperation, operation, sizeof(mOperation) - 1); + mOperation[sizeof(mOperation) - 1] = '\0'; + } else + strcpy(mOperation, operation); + } + + char *FormatError(char *str) const + { + return FormatError(str, mError); + } + + char mOperation[256]; + const OSStatus mError; + + // ------------------------------------------------- + + typedef void (*WarningHandler)(const char *msg, OSStatus err); + + static char *FormatError(char *str, OSStatus error) + { + strcpy(str, CAX4CCString(error)); + return str; + } + + static void Warning(const char *s, OSStatus error) + { + if (sWarningHandler) + (*sWarningHandler)(s, error); + } + + static void SetWarningHandler(WarningHandler f) { sWarningHandler = f; } +private: + static WarningHandler sWarningHandler; +}; + +#if DEBUG || CoreAudio_Debug + #define XThrowIfError(error, operation) \ + do { \ + OSStatus __err = error; \ + if (__err) { \ + DebugMessageN2("about to throw %s: %s", CAX4CCString(error).get(), operation);\ + STOP; \ + throw CAXException(operation, __err); \ + } \ + } while (0) + + #define XThrowIf(condition, error, operation) \ + do { \ + if (condition) { \ + OSStatus __err = error; \ + DebugMessageN2("about to throw %s: %s", CAX4CCString(error).get(), operation);\ + STOP; \ + throw CAXException(operation, __err); \ + } \ + } while (0) + + #define XRequireNoError(error, label) \ + do { \ + OSStatus __err = error; \ + if (__err) { \ + DebugMessageN2("about to throw %s: %s", CAX4CCString(error).get(), #error);\ + STOP; \ + goto label; \ + } \ + } while (0) + + #define XAssert(assertion) \ + do { \ + if (!(assertion)) { \ + DebugMessageN1("error: failed assertion: %s", #assertion);\ + STOP; \ + } \ + } while (0) + + #define XAssertNoError(error) \ + do { \ + OSStatus __err = error; \ + if (__err) { \ + DebugMessageN2("error %s: %s", CAX4CCString(error).get(), #error);\ + STOP; \ + } \ + } while (0) + +#else + #define XThrowIfError(error, operation) \ + do { \ + OSStatus __err = error; \ + if (__err) { \ + throw CAXException(operation, __err); \ + } \ + } while (0) + + #define XThrowIf(condition, error, operation) \ + do { \ + if (condition) { \ + OSStatus __err = error; \ + throw CAXException(operation, __err); \ + } \ + } while (0) + + #define XRequireNoError(error, label) \ + do { \ + OSStatus __err = error; \ + if (__err) { \ + goto label; \ + } \ + } while (0) + + #define XAssert(assertion) \ + do { \ + } while (0) + + #define XAssertNoError(error) \ + do { \ + /*OSStatus __err =*/ error; \ + } while (0) +#endif + +#define XThrow(error, operation) XThrowIf(true, error, operation) +#define XThrowIfErr(error) XThrowIfError(error, #error) + +#endif // __CAXException_h__ diff --git a/Classes/AlarmController.h b/Classes/AlarmController.h new file mode 100644 index 0000000..053da31 --- /dev/null +++ b/Classes/AlarmController.h @@ -0,0 +1,36 @@ +// +// AlarmController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 9/24/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import +#import + +@interface AlarmController : NSObject { + NSTimer *timer; + NSTimer *listenerTimer; + AVAudioPlayer *explosionSound; + AVAudioPlayer *alarmSound; + + UIAlertView *alertView; +} + ++ (AlarmController *)sharedAlarmController; + +- (void)setupAlarm:(id)sender; +- (void)setOffAlarm:(NSTimer *)theTimer; +- (IBAction)stopAlarm:(id)sender; +- (IBAction)snoozeAlarm:(id)sender; +- (NSDate *)dateAlarmWillGoOff; +- (BOOL)isHeadsetPluggedIn; + +@property (nonatomic, retain) NSTimer *timer; +//@property (nonatomic, assign) id alarmInterfaceDelegate; +@property (nonatomic, retain) AVAudioPlayer *explosionSound; +@property (nonatomic, retain) AVAudioPlayer *alarmSound; + + +@end diff --git a/Classes/AlarmController.m b/Classes/AlarmController.m new file mode 100644 index 0000000..ede0c4c --- /dev/null +++ b/Classes/AlarmController.m @@ -0,0 +1,652 @@ +// +// AlarmController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 9/24/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import "AlarmController.h" +#import "Constants.h" +#import +#import "SCListener.h" +#import "Sleep_Blaster_touchAppDelegate.h" +#import "SleepTimerController.h" +#import "DeepSleepPreventer.h" + +static AlarmController *sharedAlarmController = nil; + +@implementation AlarmController + +@synthesize timer; +@synthesize explosionSound; +@synthesize alarmSound; + +BOOL alarmIsRinging = NO; +Sleep_Blaster_touchAppDelegate *mainDelegate; + ++ (AlarmController *)sharedAlarmController { + @synchronized(self) { + if (sharedAlarmController == nil) + [[self alloc] init]; + } + + return sharedAlarmController; +} + +- (void)dealloc { + [explosionSound release]; + [alarmSound release]; + [super dealloc]; +} + +#pragma mark Alarm methods + +- (void)playSongs:(NSTimer *)timer +{ +/* MPMusicPlayerController *musicPlayerController = [MPMusicPlayerController iPodMusicPlayer]; + MPMediaQuery *everything = [[MPMediaQuery alloc] init]; + [musicPlayerController setQueueWithQuery:everything]; + [musicPlayerController setShuffleMode:MPMusicShuffleModeSongs]; +*/ + MPMusicPlayerController *musicPlayerController = [MPMusicPlayerController applicationMusicPlayer]; + + // =========================== IT'S THIS LINE RIGHT HERE THAT'S CAUSING THE PROBLEM!!!!!!! + // =========== The queue doesn't work if it's been used twice for some reason. + // ======================================================================================= + // ======================================================================================= + // ======================================================================================= + MPMediaItemCollection *collection = [MPMediaItemCollection collectionWithItems:mainDelegate.alarmSongsCollection.items]; + [musicPlayerController setQueueWithItemCollection:collection]; + + musicPlayerController.shuffleMode = MPMusicShuffleModeSongs; + [musicPlayerController play]; + + [mainDelegate showAlarmRingingView]; + +} + +- (IBAction)setupAlarm:(id)sender +{ + if (timer) { + // Either the user is changing the alarm time, or the user is turning off the alarm. + // Either way, we need to disable the timer for now. + [timer invalidate]; + + } + // If we need to, we'll turn this back on a few lines down. + if (!mainDelegate.mapViewController.view.superview) { // ...but only do this if the view isn't showing! + [mainDelegate.mapViewController stopTrackingLocation]; + + } + if (![[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue]) { + [[UIApplication sharedApplication] setIdleTimerDisabled:NO]; + return; + } + + if (![[[NSUserDefaults standardUserDefaults] objectForKey:kHasShownBackgroundMessage] boolValue]) + { + if (mainDelegate.backgroundSupported) + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Tip" message:@"When you set an alarm, it's a good idea to leave your device charging overnight, especially if you plan to leave the display on. Also, you can close Sleep Blaster and the alarm will still go off, but it will have to use Dynamite Mode because of a bug in the iPhone OS." + delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; + [alert show]; + [alert release]; + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kHasShownBackgroundMessage]; + } else { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Tip" message:@"When you set an alarm, it's a good idea to leave your device charging overnight, especially if you plan to leave the display on. Also, you must leave Sleep Blaster open for the alarm to go off!" + delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; + [alert show]; + [alert release]; + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kHasShownBackgroundMessage]; + + } + } + + + // If the alarm is set for a time.... + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] boolValue] == 0) + { + NSDate *alarmDate = [self dateAlarmWillGoOff]; + + if (!alarmDate) { + return; + } + + //[[NSUserDefaults standardUserDefaults] setObject:alarmDate forKey:kAlarmDate]; // update the date in the alarmSettings dictionary with the REAL alarm time/date. + + timer = [[[NSTimer alloc] initWithFireDate:alarmDate + interval:0 + target:self + selector:@selector(setOffAlarm:) + userInfo:nil + repeats:NO] retain]; + [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; + + NSLog(@"You will wake up at %@", alarmDate); + + // Otherwise, if the alarm is set for a place.... + } else if ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] boolValue] == 1) + { + mainDelegate.mapViewController.view; // tell the view controller to load, if it hasn't already. + [mainDelegate.mapViewController startTrackingLocation]; + } + + [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; +} + +- (IBAction)stopAlarm:(id)sender +{ + if (![[[NSUserDefaults standardUserDefaults] objectForKey:kEnableDynamiteMode] boolValue]) { + [[MPMusicPlayerController applicationMusicPlayer] stop]; + [[DeepSleepPreventer sharedDeepSleepPreventer] setAudioSessionForMediaPlayback]; + + } else { + [explosionSound stop]; + [alarmSound stop]; + } + + if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) + { + [mainDelegate hideAlarmRingingView]; + } + + UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback; + AudioSessionSetProperty ( + kAudioSessionProperty_AudioCategory, + sizeof (sessionCategory), + &sessionCategory + ); + UInt32 property = 1; +// OSStatus error; + AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(property), &property); + + alarmIsRinging = NO; + + // If the alarm is set to go off on weekdays, we need to set the timer again. + [self setupAlarm:self]; + + [[DeepSleepPreventer sharedDeepSleepPreventer] stopPreventSleep]; + +// NSTimer *newTimer = [[[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:10] +// interval:0 +// target:self +// selector:@selector(playSongs:) +// userInfo:nil +// repeats:NO] retain]; +// [[NSRunLoop currentRunLoop] addTimer:newTimer forMode:NSRunLoopCommonModes]; +} + +- (IBAction)snoozeAlarm:(id)sender +{ + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:0] forKey:kAlarmMode]; + + //NSDate *date = [[NSUserDefaults standardUserDefaults] objectForKey:kAlarmDate]; + NSDate *date = [NSDate date]; + +// NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; + + unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit; + NSDateComponents *components = [[NSCalendar currentCalendar] components:unitFlags fromDate:date]; + [components setMinute:[components minute]+[[[NSUserDefaults standardUserDefaults] objectForKey:kSnoozeMinutes] intValue]]; + + NSDate *snoozeDate = [[NSCalendar currentCalendar] dateFromComponents:components]; + + [[NSUserDefaults standardUserDefaults] setObject:snoozeDate forKey:kAlarmDate]; + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kAlarmOn]; + +// [calendar release]; + + [self stopAlarm:self]; + [self setupAlarm:self]; +} + +- (void)vibrate:(NSTimer *)theTimer { + if (!alarmIsRinging) { + [theTimer invalidate]; + return; + } + + AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); + +// SystemSoundID pmph; +// id sndpath = [[NSBundle mainBundle] +// pathForResource:@"alarm" +// ofType:@"aif"]; +// CFURLRef baseURL = (CFURLRef) [[NSURL alloc] initFileURLWithPath:sndpath]; +// AudioServicesCreateSystemSoundID (baseURL, &pmph); +// AudioServicesPlaySystemSound(pmph); +// [baseURL release]; +} + + +- (BOOL)isHeadsetPluggedIn +{ + UInt32 routeSize = sizeof (CFStringRef); + CFStringRef route; + + OSStatus error = AudioSessionGetProperty (kAudioSessionProperty_AudioRoute, + &routeSize, + &route); + + if (!error && (route != NULL) && (([route isEqual:@"Headset"]) || ([route isEqual:@"Headphone"]))) { + return YES; + } + + return NO; +} + +- (void)setOffAlarm:(NSTimer *)theTimer +{ + if ([SleepTimerController sharedSleepTimerController].sleepTimerIsOn) + { + [[SleepTimerController sharedSleepTimerController] stopSleepTimer:nil]; + } + + if (mainDelegate.bypassAlarm) + { + mainDelegate.bypassAlarm = NO; + return; + } + + if (mainDelegate.backgroundSupported) + { + UILocalNotification *notification = [[UILocalNotification alloc] init]; + notification.alertBody = @""; + notification.alertAction = @"Turn off"; + notification.userInfo = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:@"PresentedImmediately"]; + + [[UIApplication sharedApplication] presentLocalNotificationNow:notification]; + } + + [[DeepSleepPreventer sharedDeepSleepPreventer] startPreventSleep]; + + // If we're running in the background, or if there's no items in the song queue, use dynamite. + if (mainDelegate.backgroundSupported) + { + if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || + mainDelegate.alarmSongsCollection.items.count == 0) + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kEnableDynamiteMode]; + } + } else { + + if (mainDelegate.alarmSongsCollection.items.count == 0) + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kEnableDynamiteMode]; + } + + } + alarmIsRinging = YES; + + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:NO] forKey:kAlarmOn]; + + [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(vibrate:) userInfo:nil repeats:YES]; + + if (!mainDelegate.alarmSongsCollection.count) + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kEnableDynamiteMode]; + } + + if (![[[NSUserDefaults standardUserDefaults] objectForKey:kEnableDynamiteMode] boolValue]) { // if it's set to use music... + + // Fade in the iTunes volume for the amount of time set. + //[NSThread detachNewThreadSelector:@selector(graduallyIncreaseiTunesVolumeForSeconds:) toTarget:self + // withObject:[userDef objectForKey:@"TimeToIncreaseAlarmVolume"]]; + + MPMusicPlayerController *musicPlayerController = [MPMusicPlayerController applicationMusicPlayer]; + MPMediaItemCollection *collection = [MPMediaItemCollection collectionWithItems:mainDelegate.alarmSongsCollection.items]; + [musicPlayerController setQueueWithItemCollection:collection]; +// [musicPlayerController setQueueWithItemCollection:mainDelegate.alarmSongsCollection]; + + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMusicShuffle] boolValue]) { + musicPlayerController.shuffleMode = MPMusicShuffleModeSongs; + } else { + musicPlayerController.shuffleMode = MPMusicShuffleModeOff; + } + + [musicPlayerController play]; + + if (![self isHeadsetPluggedIn]) + { + [musicPlayerController setVolume:1.0]; + } + +/* + AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:[[mainDelegate.alarmSongsCollection.items objectAtIndex:0] valueForProperty:MPMediaItemPropertyAssetURL] + options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:AVURLAssetPreferPreciseDurationAndTimingKey]]; + + + + AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:urlAsset]; + //AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"alarm" ofType:@"mp3"]]]; + + AVPlayer *player = [[AVPlayer playerWithPlayerItem:playerItem] retain]; + [player play]; +*/ + + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kEnableVoiceControls] boolValue]) { + // Only enable voice controls if it's using iTunes, and not Dynamite. + + // Set the audio session for voice controls..... + UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord; + AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory); + UInt32 property = 1; + AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(property), &property); + +/* UInt32 allowMixing = true; + AudioSessionSetProperty(kAudioSessionProperty_OtherMixableAudioShouldDuck, // 1 + sizeof(allowMixing), // 2 + &allowMixing); +*/ // As long as we're not running on an iPod Touch, route the audio output to the bottom speaker. + NSString *deviceType = [UIDevice currentDevice].model; + if(![deviceType isEqualToString:@"iPod Touch"]) + { + UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; + AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOverride), &audioRouteOverride); + [musicPlayerController setVolume:1.0]; +// NSLog(@"should have set the volume up..."); + } + AudioSessionSetActive(true); + + UInt32 inputAvailableSize = sizeof(UInt32); + UInt32 inputAvailable; + AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &inputAvailableSize, &inputAvailable); + if (inputAvailable) + { + [NSThread detachNewThreadSelector:@selector(playAndPauseiTunes:) toTarget:self withObject:nil]; + } + } + + } else { // otherwise, use dynamite. + + [[MPMusicPlayerController iPodMusicPlayer] pause]; + + if (![self isHeadsetPluggedIn]) + { + [[MPMusicPlayerController iPodMusicPlayer] setVolume:1.0]; + } + explosionSound.currentTime = 0; + explosionSound.volume = 1.0; + [explosionSound play]; + } + + // Finally, update the interface to show that the alarm's ringing. + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; + if ([[[NSCalendar currentCalendar] locale] timeIs24HourFormat]) + { + [dateFormatter setDateFormat:@"HH:mm"]; + } else { + [dateFormatter setDateFormat:@"h:mma"]; + } + NSString *currentTime = [dateFormatter stringFromDate:[NSDate date]]; + + if (alertView) + { + [alertView release]; + } + alertView = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"It's %@!", currentTime] + message:@"Hey, time to wake up!" + delegate:self + cancelButtonTitle:@"Stop" + otherButtonTitles:@"Snooze", nil]; + + [alertView show]; + } else { + [mainDelegate showAlarmRingingView]; + } +} + +- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex +{ + if (buttonIndex == 0) + { + [self stopAlarm:self]; + } else { + [self snoozeAlarm:self]; + } +} + +- (void)playAndPauseiTunes:(id)sender +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + // Let iTunes play for "PlayInterval" microseconds * one million, then stop iTunes. + usleep([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmPlayInterval] intValue]*1000000); + + MPMusicPlayerController *musicPlayerController = [MPMusicPlayerController applicationMusicPlayer]; + + float originalVolume = musicPlayerController.volume; + + float rampVolume; + for (rampVolume = musicPlayerController.volume; rampVolume >= 0; rampVolume -= .04) { + [musicPlayerController setVolume:rampVolume]; + // pause 2/100th of a second (20,000 microseconds) between adjustments. + usleep(20000); + } + + // If the alarm is still ringing, listen for 2 seconds, then stop listening. + if (alarmIsRinging) { + [self performSelectorOnMainThread:@selector(startReadingVolume:) withObject:self waitUntilDone:YES]; + // Pause iTunes for "PauseInterval" microseconds * one million, then start over the loop. + usleep([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmPauseInterval] intValue]*1000000); + [self performSelectorOnMainThread:@selector(stopReadingVolume:) withObject:self waitUntilDone:YES]; + } + + // Fade the volume back in. (That DOESN'T mean iTunes is actually playing!) + //int targetVolume = [[userDef objectForKey:@"iTunesVolume"] intValue]; +// int targetVolume = 1.0; + for (rampVolume = musicPlayerController.volume; rampVolume <= originalVolume; rampVolume += .04) { + [musicPlayerController setVolume:rampVolume]; + // pause 2/100th of a second (10,000 microseconds) between adjustments. + usleep(20000); + } + + [pool release]; + + if (alarmIsRinging) { + [self playAndPauseiTunes:self]; + } +} + +- (NSDate *)dateAlarmWillGoOff +{ +// NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; + + unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit; + NSDateComponents *components = [[NSCalendar currentCalendar] components:unitFlags fromDate:[NSDate date]]; + + unitFlags = NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit; + NSDateComponents *rawAlarmDateComponents = [[NSCalendar currentCalendar] components:unitFlags fromDate:[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmDate]]; + + [components setHour:[rawAlarmDateComponents hour]]; + [components setMinute:[rawAlarmDateComponents minute]]; + [components setSecond:0]; + + // This date is the alarm time, set for today. + NSDate *alarmDate = [[NSCalendar currentCalendar] dateFromComponents:components]; + + if ([alarmDate earlierDate:[NSDate date]] == alarmDate) { // if it's already past that time today... + // set it for the same time tomorrow. + NSDateComponents *plusOneDay = [[[NSDateComponents alloc] init] autorelease]; + [plusOneDay setDay:1]; + + alarmDate = [[NSCalendar currentCalendar] dateByAddingComponents:plusOneDay toDate:alarmDate options:0]; + } + +// [calendar release]; + //[[NSUserDefaults standardUserDefaults] setObject:alarmDate forKey:kAlarmDate]; + + return alarmDate; +} + +- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag +{ + if (player == explosionSound) { + alarmSound.currentTime = 0; + alarmSound.volume = 1.0; + [alarmSound play]; + } +} + +- (void)applicationDidBecomeActive:(NSNotification *)notification +{ + NSLog(@"application did become active"); + if (alarmIsRinging) + { + NSLog(@"alarm is ringing..."); +// if (alertView.visible) +// { + NSLog(@"going to show the alert view again..."); + [alertView dismissWithClickedButtonIndex:0 animated:YES]; + [alertView show]; +// } + } +} + +#pragma mark Microphone methods +- (void)startReadingVolume:(id)sender +{ + [[SCListener sharedListener] listen]; + + if (listenerTimer) { + [listenerTimer invalidate]; + } + + listenerTimer = [[NSTimer scheduledTimerWithTimeInterval:.1 + target:self + selector:@selector(processVolumeReading) + userInfo:nil + repeats:YES] retain]; +} + +- (void)stopReadingVolume:(id)sender +{ + [listenerTimer invalidate]; + [[SCListener sharedListener] pause]; +} + +- (void)processVolumeReading +{ + float threshold = .10; + float volumeLevel = [[SCListener sharedListener] averagePower]; + if (volumeLevel > threshold) { + // stop the alarm... + + [self stopReadingVolume:self]; + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kVoiceFunction] intValue] == 0) + { + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [alertView dismissWithClickedButtonIndex:1 animated:YES]; + } + [self snoozeAlarm:self]; + + } else if ([[[NSUserDefaults standardUserDefaults] objectForKey:kVoiceFunction] intValue] == 1) + { + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [alertView dismissWithClickedButtonIndex:0 animated:YES]; + } + [self stopAlarm:self]; + } + } +} + +- (void)timeZoneDidChange:(id)notification +{ + NSTimeZone *oldTimeZone = [NSTimeZone timeZoneWithName:[[NSUserDefaults standardUserDefaults] objectForKey:kOldTimeZone]]; + + int gmtDifferenceForOldTimeZone = [oldTimeZone secondsFromGMT]; + int gmtDifferenceForNewTimeZone = [[NSTimeZone defaultTimeZone] secondsFromGMT]; + int differenceBetweenNewAndOld = gmtDifferenceForOldTimeZone - gmtDifferenceForNewTimeZone; + + if (differenceBetweenNewAndOld != 0) + { + NSDate *convertedDate = [[[AlarmController sharedAlarmController] dateAlarmWillGoOff] dateByAddingTimeInterval:differenceBetweenNewAndOld]; + [[NSUserDefaults standardUserDefaults] setObject:convertedDate forKey:kAlarmDate]; + [[AlarmController sharedAlarmController] setupAlarm:self]; + +// oldTimeZone = [NSTimeZone defaultTimeZone]; + [[NSUserDefaults standardUserDefaults] setObject:[[NSTimeZone defaultTimeZone] name] forKey:kOldTimeZone]; + } + +} + +#pragma mark - +#pragma mark Singleton Pattern + + ++ (id)allocWithZone:(NSZone *)zone { + @synchronized(self) { + if (sharedAlarmController == nil) { + sharedAlarmController = [super allocWithZone:zone]; + return sharedAlarmController; + } + } + + return nil; +} + +- (id)copyWithZone:(NSZone *)zone { + return self; +} + + +- (id)init { + if ([super init] == nil) + return nil; + + mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + + // "warm up" the microphone for later. + [[SCListener sharedListener] listen]; + [[SCListener sharedListener] pause]; + [[DeepSleepPreventer sharedDeepSleepPreventer] setAudioSessionForMediaPlayback]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(applicationDidBecomeActive:) + name:UIApplicationDidBecomeActiveNotification + object:nil]; + } + self.explosionSound = [[AVAudioPlayer alloc] initWithContentsOfURL: + [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"explosion" ofType:@"mp3"]] + error:nil]; + self.explosionSound.delegate = self; + + self.alarmSound = [[AVAudioPlayer alloc] initWithContentsOfURL: + [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"alarm" ofType:@"mp3"]] + error:nil]; + self.alarmSound.delegate = self; + self.alarmSound.numberOfLoops = -1; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(timeZoneDidChange:) + name:NSSystemTimeZoneDidChangeNotification + object:nil]; + + [self timeZoneDidChange:nil]; + + return self; +} + +- (id)retain { + return self; +} + +- (unsigned)retainCount { + return UINT_MAX; +} + +- (void)release { + // Do nothing. +} + +- (id)autorelease { + return self; +} + +@end diff --git a/Classes/AlarmSettingsViewController.h b/Classes/AlarmSettingsViewController.h new file mode 100644 index 0000000..0795342 --- /dev/null +++ b/Classes/AlarmSettingsViewController.h @@ -0,0 +1,64 @@ +// +// SecondViewController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 6/14/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import +#import +#import "CustomUISwitch.h" +#import "ShadowedLabel.h" +#import "MapViewController.h" +#import "KeypadViewController.h" + +@interface AlarmSettingsViewController : UIViewController { + IBOutlet UIDatePicker *alarmDatePicker; + IBOutlet UIView *alarmDatePickerContainerView; + IBOutlet UITableView *tableView; + IBOutlet UINavigationBar *navigationBar; + IBOutlet UILabel *amountOfTimeLabel; + CustomUISwitch *alarmSwitch; + UITableViewCell *musicCell; + KeypadViewController *keypadViewController; +//NSTimeZone *oldTimeZone; + ShadowedLabel *hourLabel2; + ShadowedLabel *hourLabel1; + ShadowedLabel *minuteLabel1; + ShadowedLabel *minuteLabel2; + ShadowedLabel *ampmLabel; + + BOOL datePickerIsShowing; +} + +- (void)toggleKeypad:(id)sender; +- (IBAction)enterDigit:(id)sender; +- (IBAction)clearDigits:(id)sender; + +- (IBAction)buttonSegmentTapped:(UIButton *)sender; +- (IBAction)toggleDatePicker:(id)sender; +- (IBAction)setAlarmDateInDatePicker:(id)sender; +- (IBAction)chooseMusic:(id)sender; + +- (void)setWakeupTimeLabel; +//- (void)alarmDidStartRinging; +- (void)setLabelInMusicCell; +- (void)setButtonSegmentImages; + +- (NSString *) deviceModel; + +- (IBAction)pushVoiceControls:(id)sender; +- (IBAction)pushMapView:(id)sender; + +- (UIButton *) getDetailDiscolosureIndicatorForIndexPath: (NSIndexPath *) indexPath; ++ (CustomUISwitch *) createSwitch; ++ (UILabel *) createLabel; ++ (ShadowedLabel *)createDigitLabel; +//- (CGSize)requiredSizeForTableView; + +@property (nonatomic, retain) UITableViewCell *musicCell; +@property (nonatomic, retain) KeypadViewController *keypadViewController; +@property (nonatomic, retain) UITableView *tableView; + +@end diff --git a/Classes/AlarmSettingsViewController.m b/Classes/AlarmSettingsViewController.m new file mode 100644 index 0000000..f903228 --- /dev/null +++ b/Classes/AlarmSettingsViewController.m @@ -0,0 +1,1535 @@ +// +// SecondViewController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 6/14/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import "AlarmController.h" +#import "AlarmSettingsViewController.h" +#import "Constants.h" +#import "Sleep_Blaster_touchAppDelegate.h" +#import "VoiceSettingsViewController.h" +#import "BlackSegmentedControl.h" +#import +#import "NSLocale+Misc.h" +#import "ShadowedLabel.h" + +#define kViewTag 1 // for tagging our embedded controls for removal at cell recycle time +#define kAlarmSwitch 101 +#define kVoiceSwitch 102 +#define kShuffleSwitch 103 +#define kDynamiteSwitch 104 +#define kShowMapCell 105 +#define kAlarmModeSegmentedControl 105 +#define VC_OFFINDICATORIMAGE_TAG 1000 +#define VC_ONINDICATORIMAGE_TAG 1001 +#define SNOOZE_TIME_LABEL_TAG 1002 +#define ALARM_TIME_LABEL_TAG 1003 +#define DYNAMITE_CELL 1004 +#define WEIRD_HEIGHT_OFFSET_FOR_SOME_REASON 37 + +//static int kModeSectionIndex = 0; +//static int kAlarmSettingsSectionIndex = 1; +//static int kMusicSettingsSectionIndex = 2; + +@implementation AlarmSettingsViewController + +BOOL keypadIsShowing = NO; +BOOL indicatorLightWasOn = NO; + +@synthesize musicCell; +@synthesize keypadViewController; +@synthesize tableView; + + + // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + + self.title = @"Alarm Clock"; + + UIImage* anImage = [UIImage imageNamed:@"clockIcon.png"]; + UITabBarItem* theItem = [[UITabBarItem alloc] initWithTitle:@"Alarm Clock" image:anImage tag:0]; + self.tabBarItem = theItem; + [theItem release]; + } + return self; +} + +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad { + [super viewDidLoad]; + +// CGSize size = {320, 540}; +// size.height += 37; // For some reason, only here, we have to add 37 pixels to the height. It has something to do with the navigation controller. +// Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; +// [mainDelegate.clockViewController.alarmPopoverController setPopoverContentSize:size]; + + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(timeZoneDidChange:) + name:NSSystemTimeZoneDidChangeNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(userDefaultsChanged:) + name:NSUserDefaultsDidChangeNotification + object:[NSUserDefaults standardUserDefaults]]; + + + +// [AlarmController sharedAlarmController].alarmInterfaceDelegate = self; + + // + // Change the properties of the imageView and tableView (these could be set + // in interface builder instead). + // + tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + +// if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) +// { +// tableView.rowHeight = 60; +/* } else { + tableView.rowHeight = 50; + }*/ + tableView.backgroundColor = [UIColor clearColor]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + // The device is an iPad running iPhone 3.2 or later. + [tableView setBackgroundView:nil]; + [tableView setBackgroundView:[[[UIView alloc] init] autorelease]]; + } + + + // Initialize the datepicker + + [alarmDatePicker setDate:[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmDate] animated:NO]; + CGRect alarmDatePickerContainerViewFrame = alarmDatePickerContainerView.frame; + alarmDatePickerContainerViewFrame.origin.y = self.view.frame.size.height; + alarmDatePickerContainerView.frame = alarmDatePickerContainerViewFrame; + [self.view addSubview:alarmDatePickerContainerView]; + + datePickerIsShowing = NO; + alarmDatePickerContainerView.hidden = YES; + navigationBar.barStyle = UIBarStyleBlack; + navigationBar.translucent = YES; + +// self.contentSizeForViewInPopover = [self requiredSizeForTableView]; +} + + +- (void)timeZoneDidChange:(id)notification +{ + alarmDatePicker.timeZone = [NSTimeZone defaultTimeZone]; + [self setWakeupTimeLabel]; +} + +- (IBAction)toggleDatePicker:(id)sender +{ +// Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; +// CGSize size = mainDelegate.alarmSettingsNavigationController.view.frame.size; + + if (datePickerIsShowing) + { + CGRect originalFrame = alarmDatePickerContainerView.frame; + CGRect newFrame = originalFrame; + newFrame.origin.y = self.view.frame.size.height; + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.5]; +// alarmDatePickerContainerView.transform = CGAffineTransformMakeTranslation(0, alarmDatePickerContainerView.frame.size.height+69); + alarmDatePickerContainerView.frame = newFrame; + [UIView commitAnimations]; + + datePickerIsShowing = NO; + } else { + + alarmDatePickerContainerView.hidden = NO; + + NSDate *alarmDate = [[AlarmController sharedAlarmController] dateAlarmWillGoOff]; + int hoursUntilWakeup = floor([alarmDate timeIntervalSinceNow]/3600); + int minutesUntilWakeup = floor(([alarmDate timeIntervalSinceNow]-hoursUntilWakeup*3600)/60); + NSString *amountOfTimeString = [NSString stringWithFormat:@"In %d hours and %d minutes", hoursUntilWakeup, minutesUntilWakeup]; + amountOfTimeLabel.text = amountOfTimeString; + +// alarmDatePicker.timeZone = [NSTimeZone localTimeZone]; +// NSLog([[NSTimeZone localTimeZone] description]); + alarmDatePicker.date = alarmDate; + + CGRect originalFrame = alarmDatePickerContainerView.frame; + CGRect newFrame = originalFrame; + newFrame.origin.y = self.view.frame.size.height - originalFrame.size.height; + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.5]; +// alarmDatePickerContainerView.transform = CGAffineTransformMakeTranslation(0, -(alarmDatePickerContainerView.frame.size.height+69)); + alarmDatePickerContainerView.frame = newFrame; + [UIView commitAnimations]; + + datePickerIsShowing = YES; + } +} + +- (IBAction)setAlarmDateInDatePicker:(id)sender +{ + [[NSUserDefaults standardUserDefaults] setObject:[sender date] forKey:kAlarmDate]; + [[AlarmController sharedAlarmController] setupAlarm:self]; + +/* NSDate *alarmDate = [[AlarmController sharedAlarmController] dateAlarmWillGoOff]; + int hoursUntilWakeup = floor([alarmDate timeIntervalSinceNow]/3600); + int minutesUntilWakeup = floor(([alarmDate timeIntervalSinceNow]-hoursUntilWakeup*3600)/60); + NSString *amountOfTimeString = [NSString stringWithFormat:@"In %d hours and %d minutes", hoursUntilWakeup, minutesUntilWakeup]; + amountOfTimeLabel.text = amountOfTimeString; +*/ + [self setWakeupTimeLabel]; +} + +- (void)setWakeupTimeLabel +{ + NSDate *alarmDate = [[AlarmController sharedAlarmController] dateAlarmWillGoOff]; + int hoursUntilWakeup = floor([alarmDate timeIntervalSinceNow]/3600); + int minutesUntilWakeup = floor(([alarmDate timeIntervalSinceNow]-hoursUntilWakeup*3600)/60); + NSString *amountOfTimeString = [NSString stringWithFormat:@"In %d hours and %d minutes", hoursUntilWakeup, minutesUntilWakeup]; + amountOfTimeLabel.text = amountOfTimeString; +} + + +/*- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration +{ + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + [self.tabBarController dismissModalViewControllerAnimated:YES]; + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + + CGSize size = {320, 480}; + self.contentSizeForViewInPopover = size; + size.height += 37; + [mainDelegate.clockViewController.alarmPopoverController setPopoverContentSize:size]; + [mainDelegate.clockViewController.alarmPopoverController dismissPopoverAnimated:NO]; + [mainDelegate.clockViewController.alarmPopoverController presentPopoverFromRect:mainDelegate.clockViewController.rightSettingsButton.frame inView:mainDelegate.clockViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO]; + + } +} +*/ +- (IBAction) chooseMusic: (id) sender { + + MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAnyAudio]; + + picker.delegate = self; + picker.allowsPickingMultipleItems = YES; + picker.prompt = NSLocalizedString (@"Add songs to wake up to", "Prompt in media item picker"); + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + picker.modalPresentationStyle = UIModalPresentationCurrentContext; + } + // The media item picker uses the default UI style, so it needs a default-style + // status bar to match it visually + [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: YES]; + + [self.tabBarController presentModalViewController:picker animated:YES]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + CGSize size = {320, 480}; + self.contentSizeForViewInPopover = size; + } + + [picker release]; +} + +// Responds to the user tapping Done after choosing music. +- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection +{ + [self.tabBarController dismissModalViewControllerAnimated:YES]; + + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + CGSize size = {320, 480}; + self.contentSizeForViewInPopover = size; + size.height += 37; + [mainDelegate.clockViewController.alarmPopoverController setPopoverContentSize:size]; + [mainDelegate.clockViewController.alarmPopoverController dismissPopoverAnimated:NO]; + [mainDelegate.clockViewController.alarmPopoverController presentPopoverFromRect:mainDelegate.clockViewController.rightSettingsButton.frame inView:mainDelegate.clockViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO]; + } + // Save the alarm songs collection to the user defaults... + NSData *alarmSongsData = [NSKeyedArchiver archivedDataWithRootObject:mediaItemCollection]; + [[NSUserDefaults standardUserDefaults] setObject:alarmSongsData forKey:kAlarmSongsCollection]; + + mainDelegate.alarmSongsCollection = mediaItemCollection; + + [self setLabelInMusicCell]; + + [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque animated:YES]; +} + +// Responds to the user tapping done having chosen no music. +- (void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker { + + [self.tabBarController dismissModalViewControllerAnimated: YES]; + + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + CGSize size = {320, 480}; + self.contentSizeForViewInPopover = size; + size.height += 37; + [mainDelegate.clockViewController.alarmPopoverController setPopoverContentSize:size]; + [mainDelegate.clockViewController.alarmPopoverController dismissPopoverAnimated:NO]; + [mainDelegate.clockViewController.alarmPopoverController presentPopoverFromRect:mainDelegate.clockViewController.rightSettingsButton.frame inView:mainDelegate.clockViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO]; + } + [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque animated:YES]; +} + +- (void)switchFlipped:(UISwitch *)sender +{ + switch (sender.tag) { + case kAlarmSwitch: + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[sender isOn]] forKey:kAlarmOn]; + [[AlarmController sharedAlarmController] setupAlarm:self]; + + break; + } + case kShuffleSwitch: + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[sender isOn]] forKey:kAlarmMusicShuffle]; + break; + } + case kVoiceSwitch: + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[sender isOn]] forKey:kEnableVoiceControls]; + break; + } + case kDynamiteSwitch: + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[sender isOn]] forKey:kEnableDynamiteMode]; + // Hide/show the music settings section, depending on whether Dynamite Mode was turned on or off. + + UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectZero]; + UIImageView *selectedBackgroundImageView = [[UIImageView alloc] initWithFrame:CGRectZero]; + + if ([sender isOn]) { + //[tableView deleteSections:[NSIndexSet indexSetWithIndex:2] withRowAnimation:UITableViewRowAnimationFade]; + + NSArray *indexPaths = [NSArray arrayWithObjects: + [NSIndexPath indexPathForRow:7 inSection:0], + [NSIndexPath indexPathForRow:8 inSection:0], + [NSIndexPath indexPathForRow:9 inSection:0], + nil]; + [tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade]; + + } else { + //[tableView insertSections:[NSIndexSet indexSetWithIndex:2] withRowAnimation:UITableViewRowAnimationFade]; + + NSArray *indexPaths = [NSArray arrayWithObjects: + [NSIndexPath indexPathForRow:7 inSection:0], + [NSIndexPath indexPathForRow:8 inSection:0], + [NSIndexPath indexPathForRow:9 inSection:0], + nil]; + [tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade]; + + backgroundImageView.image = [UIImage imageNamed:@"lightRow.png"]; + selectedBackgroundImageView.image = [UIImage imageNamed:@"lightRow.png"]; + + [tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:9 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES]; + + } + + UITableViewCell *dynamiteCell = (UITableViewCell *)[self.view viewWithTag:DYNAMITE_CELL]; + dynamiteCell.backgroundView = backgroundImageView; + dynamiteCell.selectedBackgroundView = selectedBackgroundImageView; + + + + + // [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:6 inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; + // [tableView reloadData]; + + break; + } + default: + break; + } +} + +/*- (CGSize)requiredSizeForTableView +{ + CGSize size = tableView.frame.size; + int sections = [self numberOfSectionsInTableView:tableView]; + int totalRows = 0; + for (int i = 0; i < sections; i++) + { + totalRows += [self tableView:tableView numberOfRowsInSection:i]; + } + + size.height = tableView.rowHeight*(totalRows+sections-1); + NSLog(@"should now be %f", size.height); + return size; + +// self.contentSizeForViewInPopover = rect.size; +}*/ + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + +- (void)viewWillAppear:(BOOL)animated +{ + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + CGSize size = {320, 480}; + self.contentSizeForViewInPopover = size; + } +// CGRect viewFrame = self.view.frame; +// viewFrame.origin.y = 100.0; +// self.view.frame = viewFrame; + [tableView reloadData]; + +// CGSize size = {320, 480}; + //Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + //CGSize size = ((AlarmSettingsViewController *)[mainDelegate.alarmSettingsNavigationController.viewControllers objectAtIndex:0]).view.frame.size; + +// self.contentSizeForViewInPopover = [self requiredSizeForTableView]; +// Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; +// mainDelegate.clockViewController.alarmPopoverController.popoverContentSize = self.view.frame.size; +// self.contentSizeForViewInPopover = self.view.frame.size; + + [super viewWillAppear:animated]; +} + +- (void)viewDidDisappear:(BOOL)animated +{ + if (keypadViewController) + { + if (keypadIsShowing) + { + // Get ready to move the keypadView out of visibility. + CGRect keypadViewFrame = keypadViewController.view.frame; + keypadViewFrame.origin.y += (KEYPAD_HEIGHT_MINUS_SHADOW + BOTTOMBAR_HEIGHT); + + // Get ready to move the main view back down to fill the screen again. + CGRect mainViewFrame = self.view.frame; + mainViewFrame.origin.y += (KEYPAD_HEIGHT_MINUS_SHADOW - 60); + + self.view.frame = mainViewFrame; + keypadViewController.view.frame = keypadViewFrame; + [keypadViewController.view removeFromSuperview]; + + + keypadIsShowing = NO; + } + } +} + +- (void)dealloc { + [super dealloc]; +} + +- (void)setLabelInMusicCell +{ + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + NSString *musicString = nil; + + if (mainDelegate.hasLoadedAlarmSongsCollection) // if it's finished loading (whether there's any song data or not)... + { + if (!mainDelegate.alarmSongsCollection) { + musicString = @"Select songs"; + } else if (mainDelegate.alarmSongsCollection.count > 1) { + musicString = [NSString stringWithFormat:@"%d songs", mainDelegate.alarmSongsCollection.items.count]; + } else if (mainDelegate.alarmSongsCollection.count == 1) { + musicString = [[mainDelegate.alarmSongsCollection.items objectAtIndex:0] valueForProperty:MPMediaItemPropertyTitle]; + } + [self.musicCell.textLabel setText:musicString]; + } else { // otherwise, it hasn't finished loading yet. + musicCell.textLabel.text = @"Loading songs..."; + } +} + ++ (CustomUISwitch *)createSwitch +{ + CGRect frame = CGRectMake(198.0, 9.0, 84.0, 27.0); + CustomUISwitch *theSwitch; + +// if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) +// { +// // The device is an iPad running iPhone 3.2 or later. + theSwitch = [[[CustomUISwitch alloc] initWithFrame:frame lighter:YES] autorelease]; +// } else { +// theSwitch = [[[CustomUISwitch alloc] initWithFrame:frame lighter:NO] autorelease]; +// } + + // in case the parent view draws with a custom color or gradient, use a transparent color + theSwitch.backgroundColor = [UIColor clearColor]; + +// [theSwitch setAccessibilityLabel:NSLocalizedString(@"StandardSwitch", @"")]; + + theSwitch.tag = kViewTag; // tag this view for later so we can remove it from recycled table cells + return theSwitch; +} + ++ (UILabel *)createLabel +{ + CGRect frame = CGRectMake(198.0, 9.0, 94.0, 26.0); + UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease]; + label.backgroundColor = [UIColor clearColor]; + label.textAlignment = UITextAlignmentRight; +// label.highlightedTextColor = [UIColor whiteColor]; + label.font = [UIFont systemFontOfSize:[UIFont labelFontSize]]; + label.textColor = [UIColor colorWithRed:0.243 green:0.306 blue:0.435 alpha:1.0]; + + label.tag = kViewTag; // tag this view for later so we can remove it from recycled table cells + return label; +} + ++ (ShadowedLabel *)createDigitLabel +{ + ShadowedLabel *label = [[[ShadowedLabel alloc] initWithFrame:CGRectZero] autorelease]; + [label setShadowBlur:.1]; // can't set the shadow blur to 0.0, because then it will show up as !shadowBlur and will default to 5.0. + label.textAlignment = UITextAlignmentRight; + label.font = [UIFont fontWithName:@"Digital-7" size:20.0]; + label.textColor = [UIColor colorWithRed:.40 green:.85 blue:1 alpha:1]; + label.backgroundColor = [UIColor clearColor]; + + return label; +} + +- (void)setAlarmDigitLabels +{ + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + + if ([[[NSCalendar currentCalendar] locale] timeIs24HourFormat]) + { + [dateFormatter setDateFormat:@"HH:mm"]; + } else { + [dateFormatter setDateFormat:@"h:mm a"]; + } + NSString *currentTime = [dateFormatter stringFromDate:[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmDate]]; + + UILabel *alarmTimeLabel = (UILabel *)[self.view viewWithTag:ALARM_TIME_LABEL_TAG]; + alarmTimeLabel.text = currentTime; +} + +- (void)userDefaultsChanged:(NSNotification *)notification +{ +// NSLog(@"defaults changed!"); + + [self setAlarmDigitLabels]; + +/* UIImageView *indicatorImageView = (UIImageView *)[self.view viewWithTag:VC_OFFINDICATORIMAGE_TAG]; + + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kEnableVoiceControls] boolValue]) { + [indicatorImageView setImage:[UIImage imageNamed:@"indicatorLightOn.png"]]; + } else { + [indicatorImageView setImage:[UIImage imageNamed:@"indicatorLightOff-iPad.png"]]; + } +*/ + if (((NSArray *)[[NSUserDefaults standardUserDefaults] objectForKey:kLocationPoints]).count > 0) + { + [((UITableViewCell *)[self.view viewWithTag:kShowMapCell]).textLabel setText:@"Show on Map"]; + } else { + [((UITableViewCell *)[self.view viewWithTag:kShowMapCell]).textLabel setText:@"Set Place"]; + } + + UILabel *snoozeTimeLabel = (UILabel *)[self.view viewWithTag:SNOOZE_TIME_LABEL_TAG]; + [snoozeTimeLabel setText:[[[NSUserDefaults standardUserDefaults] objectForKey:kSnoozeMinutes] stringValue]]; +} + +- (IBAction)pushVoiceControls:(id)sender +{ +// Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + + VoiceSettingsViewController *controller; + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + controller = [[VoiceSettingsViewController alloc] initWithNibName:@"VoiceSettingsView-iPad" bundle:nil]; + } else { + controller = [[VoiceSettingsViewController alloc] initWithNibName:@"VoiceSettingsView" bundle:nil]; + controller.hidesBottomBarWhenPushed = YES; + } + [[self navigationController] pushViewController:controller animated:YES]; + [controller release]; +} + +- (IBAction)pushMapView:(id)sender +{ + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + mainDelegate.mapViewController.hidesBottomBarWhenPushed = YES; + [[self navigationController] pushViewController:mainDelegate.mapViewController animated:YES]; +} + +- (void)setButtonSegmentImages +{ + int value = [[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] intValue]; + if (value == 0) + { + [((UIButton *)[self.view viewWithTag:LEFT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlTimeSelected.png"] + forState:UIControlStateNormal]; + [((UIButton *)[self.view viewWithTag:RIGHT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlPlaceDeselected.png"] + forState:UIControlStateNormal]; + } else if (value == 1 ) { + [((UIButton *)[self.view viewWithTag:LEFT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlTimeDeselected.png"] + forState:UIControlStateNormal]; + [((UIButton *)[self.view viewWithTag:RIGHT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlPlaceSelected.png"] + forState:UIControlStateNormal]; + } +} + +- (IBAction)buttonSegmentTapped:(UIButton *)sender +{ + if (sender.tag == LEFT_BUTTON_SEGMENT) + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:0] + forKey:kAlarmMode]; + + } else if (sender.tag == RIGHT_BUTTON_SEGMENT) { + + NSString *deviceModel = [self deviceModel]; +// NSLog(deviceModel); + +// if ([[UIDevice currentDevice].model isEqualToString:@"iPhone"] && +// ![deviceModel isEqualToString:@"iPhone1,1"]) { + + + CLLocationManager *locationManager = [[CLLocationManager alloc] init]; +// NSLog(@"%f", ((double)[[locationManager location] verticalAccuracy])); + if (([[UIDevice currentDevice].model isEqualToString:@"iPhone"] && ![deviceModel isEqualToString:@"iPhone1,1"]) || + /*((double)[[locationManager location] verticalAccuracy]) != 0*/ + UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:1] + forKey:kAlarmMode]; + + } else { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"GPS Required" + message:@"To use the map feature, you must have a GPS-enabled device." + delegate:self + cancelButtonTitle:@"OK" + otherButtonTitles:nil, nil]; + [alert show]; + [alert release]; + } + [locationManager release]; + } + + + // This line automatically updates the images of the segmented control. + [tableView reloadData]; + // And this line gives it a smoother transition when it's changing the "alarm time" cell to the "show map" cell. + [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:1 inSection:0]] + withRowAnimation:UITableViewRowAnimationFade]; + + [self setButtonSegmentImages]; + + [[AlarmController sharedAlarmController] setupAlarm:self]; +} + +- (NSString *) deviceModel{ + size_t size; + sysctlbyname("hw.machine", NULL, &size, NULL, 0); + char *answer = malloc(size); + sysctlbyname("hw.machine", answer, &size, NULL, 0); + NSString *results = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding]; + free(answer); + return results; +} + +- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated +{ +// referenceToPopoverController.popoverContentSize = viewController.view.frame.size; + + + UIImageView *offIndicatorImageView = (UIImageView *)[self.view viewWithTag:VC_OFFINDICATORIMAGE_TAG]; + UIImageView *onIndicatorImageView = (UIImageView *)[self.view viewWithTag:VC_ONINDICATORIMAGE_TAG]; + + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kEnableVoiceControls] boolValue]) { + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:1.0]; + + offIndicatorImageView.alpha = 0.0; + onIndicatorImageView.alpha = 1.0; + + [UIView commitAnimations]; + + indicatorLightWasOn = YES; + + } else { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:1.0]; + + offIndicatorImageView.alpha = 1.0; + onIndicatorImageView.alpha = 0.0; + + [UIView commitAnimations]; + + indicatorLightWasOn = NO; + } +} + +#pragma mark keypad functions + +- (void)toggleKeypad:(id)sender +{ + if (keypadIsShowing) + { + // Get ready to move the keypadView out of visibility. + CGRect keypadViewFrame = self.keypadViewController.view.frame; +// keypadViewFrame.origin.y += (KEYPAD_HEIGHT_MINUS_SHADOW + BOTTOMBAR_HEIGHT); + keypadViewFrame.origin.y = self.view.frame.size.height; + + // Get ready to move the main view back down to fill the screen again. + CGRect mainViewFrame = self.view.frame; + mainViewFrame.origin.y += (KEYPAD_HEIGHT_MINUS_SHADOW - 60); + + [UIView beginAnimations:@"keypad" context:NULL]; + [UIView setAnimationDuration:1.0]; + + self.view.frame = mainViewFrame; + self.keypadViewController.view.frame = keypadViewFrame; + + [UIView setAnimationDelegate:self]; + [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; + [UIView commitAnimations]; + + keypadIsShowing = NO; + } else { + // Add the keypadView as a subview, and stick it below the very bottom of the screen. + if (!self.keypadViewController) { + self.keypadViewController = [[[KeypadViewController alloc] initWithNibName:@"KeypadView" bundle:nil] retain]; + self.keypadViewController.delegate = self; + } + [self.view.superview addSubview:self.keypadViewController.view]; + + CGRect keypadViewFrame = self.keypadViewController.view.frame; + keypadViewFrame.size.height = 230; +// keypadViewFrame.origin.y = (480) - MENUBAR_HEIGHT - 20; // height of the screen minus the height of the menubar and the shadow + keypadViewFrame.origin.y = self.view.frame.size.height; + self.keypadViewController.view.frame = keypadViewFrame; + + // Get ready to move the keypadView into visibility. +// keypadViewFrame.origin.y -= (KEYPAD_HEIGHT_MINUS_SHADOW + BOTTOMBAR_HEIGHT); + keypadViewFrame.origin.y = self.view.frame.size.height - keypadViewFrame.size.height; + + // Get ready to move the main view up to make room for the keypadView. + CGRect mainViewFrame = self.view.frame; + mainViewFrame.origin.y -= (KEYPAD_HEIGHT_MINUS_SHADOW - 60); // let the keyboard "catch up" an additional 80 pixels + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:1.0]; + + self.view.frame = mainViewFrame; + self.keypadViewController.view.frame = keypadViewFrame; + + [UIView commitAnimations]; + + + keypadIsShowing = YES; + } +} + + +- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context +{ + if ([animationID isEqualToString:@"keypad"]) + { + [self.keypadViewController.view removeFromSuperview]; + } +} + +- (IBAction)enterDigit:(id)sender +{ + int originalNumber = [[[NSUserDefaults standardUserDefaults] objectForKey:kSnoozeMinutes] intValue]; + + int newNumber = originalNumber * 10 + ((UIButton *)sender).tag; + if (newNumber >= 99) { + newNumber = ((UIButton *)sender).tag; // don't let it be more than two digits + } + + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:newNumber] forKey:kSnoozeMinutes]; +} + +- (IBAction)clearDigits:(id)sender +{ + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:0] forKey:kSnoozeMinutes]; +} + +#pragma mark UITableViewDelegate + +/*- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section +{ +// if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) +// { +// return 60.0; +// } else { + if (section == kModeSectionIndex) + { + return 80.0; + } else { + return 60.0; + } +// } +}*/ + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (indexPath.row == 0) + { + return 100.0; + } else { + return 60.0; + } +} + +/*- (UIView *)tableView:(UITableView *)theTableView viewForHeaderInSection:(NSInteger)section +{ + if (section == kModeSectionIndex) + { + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200 + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + // The device is an iPad running iPhone 3.2 or later. + return nil; + } + else +#endif + { + // The device is an iPhone or iPod touch. + UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 80.0)] autorelease]; + + UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 10.0, tableView.frame.size.width, 20.0)]; + label.text = @"Wake me up at a certain..."; + label.textAlignment = UITextAlignmentCenter; + label.backgroundColor = [UIColor clearColor]; + label.textColor = [UIColor colorWithRed:.1 green:.1 blue:.1 alpha:1.0]; + label.shadowColor = [UIColor whiteColor]; + label.shadowOffset = CGSizeMake(0, 1); + [view addSubview:label]; + [label release]; + + UIButton *timeButtonSegment = [UIButton buttonWithType:UIButtonTypeCustom]; + timeButtonSegment.frame = CGRectMake(tableView.frame.size.width/2 - 103.0, label.frame.size.height+label.frame.origin.y+10.0, 103.0, 40.0); + timeButtonSegment.tag = LEFT_BUTTON_SEGMENT; + [timeButtonSegment addTarget:self action:@selector(buttonSegmentTapped:) forControlEvents:UIControlEventTouchUpInside]; + + UIButton *placeButtonSegment = [UIButton buttonWithType:UIButtonTypeCustom]; + placeButtonSegment.frame = CGRectMake(tableView.frame.size.width/2, label.frame.size.height+label.frame.origin.y+10.0, 103.0, 40.0); + placeButtonSegment.tag = RIGHT_BUTTON_SEGMENT; + [placeButtonSegment addTarget:self action:@selector(buttonSegmentTapped:) forControlEvents:UIControlEventTouchUpInside]; + + int value = [[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] intValue]; + if (value == 0) + { + [timeButtonSegment setBackgroundImage:[UIImage imageNamed:@"segmentedControlTimeSelected.png"] + forState:UIControlStateNormal]; + [placeButtonSegment setBackgroundImage:[UIImage imageNamed:@"segmentedControlPlaceDeselected.png"] + forState:UIControlStateNormal]; + } else if (value == 1 ) { + [timeButtonSegment setBackgroundImage:[UIImage imageNamed:@"segmentedControlTimeDeselected.png"] + forState:UIControlStateNormal]; + [placeButtonSegment setBackgroundImage:[UIImage imageNamed:@"segmentedControlPlaceSelected.png"] + forState:UIControlStateNormal]; + } + + [view addSubview:timeButtonSegment]; + [view addSubview:placeButtonSegment]; + + return view; + } + + + } else { + +// if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) +// { + UIImage *rowBackground = [UIImage imageNamed:@"lightRow.png"]; + UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 10.0, rowBackground.size.width, 60.0)]; + backgroundImageView.image = rowBackground; + + return backgroundImageView; + +// } else { +// theTableView.sectionHeaderHeight = 40; +// UILabel *headerLabel = [[[ShadowedLabel alloc] initWithFrame:CGRectMake(0, 40, 300, 40)] autorelease]; +// headerLabel.text = [self tableView:tableView titleForHeaderInSection:section]; +// headerLabel.textColor = [UIColor colorWithRed:.69 green:.90 blue:.98 alpha:1]; +// headerLabel.font = [UIFont boldSystemFontOfSize:14]; +// headerLabel.backgroundColor = [UIColor clearColor]; +// headerLabel.textAlignment = UITextAlignmentCenter; +// +// return headerLabel; +// } + + } +} +*/ +- (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView +{ +// if ([[[NSUserDefaults standardUserDefaults] objectForKey:kEnableDynamiteMode] boolValue]) { +// return 2; +// } else { +// return 3; +// } + + return 1; + +} + +/*- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + if (section == kAlarmSettingsSectionIndex) { + return @"ALARM SETTINGS"; + } else if (section == kMusicSettingsSectionIndex) { + return @"MUSIC SETTINGS"; + } else if (section == kModeSectionIndex) { + return @""; + } +} +*/ +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ +/* if (section == kAlarmSettingsSectionIndex) { + return 4; + } else if (section == kMusicSettingsSectionIndex) { + return 2; + } else if (section == kModeSectionIndex) { + return 1; + } + */ + + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kEnableDynamiteMode] boolValue]) + { + return 7; + } else { + return 10; + } +} + +- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath +{ + cell.opaque = NO; + cell.backgroundColor = [UIColor clearColor]; +} + +- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease]; + + cell.textLabel.backgroundColor = [UIColor clearColor]; + cell.textLabel.textColor = [UIColor colorWithRed:.1 green:.1 blue:.1 alpha:1.0]; + cell.textLabel.highlightedTextColor = [UIColor colorWithRed:.1 green:.1 blue:.1 alpha:1.0]; + cell.textLabel.shadowColor = [UIColor whiteColor]; + cell.textLabel.shadowOffset = CGSizeMake(0, 1); + + + switch ([indexPath row]) { + + case 0: { + +// if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) +// { + // The device is an iPhone or iPod touch. + UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 80.0)] autorelease]; + + UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 10.0, tableView.frame.size.width, 20.0)]; + label.text = @"Wake me up at a certain..."; + label.textAlignment = UITextAlignmentCenter; + label.backgroundColor = [UIColor clearColor]; + label.textColor = [UIColor colorWithRed:.1 green:.1 blue:.1 alpha:1.0]; + label.shadowColor = [UIColor whiteColor]; + label.shadowOffset = CGSizeMake(0, 1); + [view addSubview:label]; + [label release]; + + UIButton *timeButtonSegment = [UIButton buttonWithType:UIButtonTypeCustom]; + timeButtonSegment.frame = CGRectMake(tableView.frame.size.width/2 - 103.0, label.frame.size.height+label.frame.origin.y+10.0, 103.0, 40.0); + timeButtonSegment.tag = LEFT_BUTTON_SEGMENT; + [timeButtonSegment addTarget:self action:@selector(buttonSegmentTapped:) forControlEvents:UIControlEventTouchUpInside]; + + UIButton *placeButtonSegment = [UIButton buttonWithType:UIButtonTypeCustom]; + placeButtonSegment.frame = CGRectMake(tableView.frame.size.width/2, label.frame.size.height+label.frame.origin.y+10.0, 103.0, 40.0); + placeButtonSegment.tag = RIGHT_BUTTON_SEGMENT; + [placeButtonSegment addTarget:self action:@selector(buttonSegmentTapped:) forControlEvents:UIControlEventTouchUpInside]; + + int value = [[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] intValue]; + if (value == 0) + { + [timeButtonSegment setBackgroundImage:[UIImage imageNamed:@"segmentedControlTimeSelected.png"] + forState:UIControlStateNormal]; + [placeButtonSegment setBackgroundImage:[UIImage imageNamed:@"segmentedControlPlaceDeselected.png"] + forState:UIControlStateNormal]; + } else if (value == 1 ) { + [timeButtonSegment setBackgroundImage:[UIImage imageNamed:@"segmentedControlTimeDeselected.png"] + forState:UIControlStateNormal]; + [placeButtonSegment setBackgroundImage:[UIImage imageNamed:@"segmentedControlPlaceSelected.png"] + forState:UIControlStateNormal]; + } + + [view addSubview:timeButtonSegment]; + [view addSubview:placeButtonSegment]; + + [cell.contentView addSubview:view]; +// } + + break; + + } + + case 1: { + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] intValue] == 0) + { + [cell.textLabel setText:@"Alarm Time"]; + + // UIImage *lcd = [UIImage imageNamed:@"alarmMiniLCD.png"]; + // // CAUSES A CRASHER WHEN YOU RELEASE THIS AT ANY TIME FOR SOME REASON + // UIImageView *lcdImageView = [[UIImageView alloc] initWithFrame:CGRectMake(200.0, (tableView.rowHeight/2)-(lcd.size.height/2), lcd.size.width, lcd.size.height)]; + // [lcdImageView setImage:lcd]; + // [lcdImageView setOpaque:NO]; + + UIImage *blackScreen = [UIImage imageNamed:@"blackScreen.png"]; + UIImageView *lcdImageView = [[UIImageView alloc] initWithFrame:CGRectMake(195.0, ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(blackScreen.size.height/2), blackScreen.size.width, blackScreen.size.height)]; + [lcdImageView setImage:blackScreen]; + [cell.contentView addSubview:lcdImageView]; + + // hourLabel1 = [AlarmSettingsViewController createDigitLabel]; + // hourLabel1.frame = CGRectMake(11.0, 0.0, 10.0, 34.0); + // [lcdImageView addSubview:hourLabel1]; + // + // hourLabel2 = [AlarmSettingsViewController createDigitLabel]; + // hourLabel2.frame = CGRectMake(21.0, 0.0, 10.0, 34.0); + // [lcdImageView addSubview:hourLabel2]; + // + // ShadowedLabel *colonLabel = [AlarmSettingsViewController createDigitLabel]; + // colonLabel.frame = CGRectMake(30.0, 0.0, 5.0, 34.0); + // colonLabel.text = @":"; + // [lcdImageView addSubview:colonLabel]; + // + // minuteLabel1 = [AlarmSettingsViewController createDigitLabel]; + // minuteLabel1.frame = CGRectMake(34.0, 0.0, 10.0, 34.0); + // [lcdImageView addSubview:minuteLabel1]; + // + // minuteLabel2 = [AlarmSettingsViewController createDigitLabel]; + // minuteLabel2.frame = CGRectMake(44.0, 0.0, 10.0, 34.0); + // [lcdImageView addSubview:minuteLabel2]; + // + // ampmLabel = [AlarmSettingsViewController createDigitLabel]; + // ampmLabel.frame = CGRectMake(55.0, 0.0, 20.0, 34.0); + // [lcdImageView addSubview:ampmLabel]; + + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + if ([[[NSCalendar currentCalendar] locale] timeIs24HourFormat]) + { + [dateFormatter setDateFormat:@"HH:mm"]; + } else { + [dateFormatter setDateFormat:@"h:mm a"]; + } + NSString *currentTime = [dateFormatter stringFromDate:[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmDate]]; + + ShadowedLabel *alarmTimeLabel = [[ShadowedLabel alloc] initWithFrame:CGRectMake(lcdImageView.frame.origin.x+lcdImageView.frame.size.width/2-100.0/2, ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(27.0/2), 100.0, 27.0)]; + alarmTimeLabel.textAlignment = UITextAlignmentCenter; + alarmTimeLabel.font = [UIFont boldSystemFontOfSize:12.0]; + alarmTimeLabel.textColor = [UIColor colorWithRed:.72 green:.91 blue:1.0 alpha:1.0]; + alarmTimeLabel.shadowColor = [UIColor colorWithRed:0.0 green:.52 blue:1.0 alpha:.9]; + alarmTimeLabel.shadowBlur = 10.0; + alarmTimeLabel.backgroundColor = [UIColor clearColor]; + [alarmTimeLabel setText:currentTime]; + alarmTimeLabel.tag = ALARM_TIME_LABEL_TAG; + [cell.contentView addSubview:alarmTimeLabel]; + [alarmTimeLabel release]; + + // [self setAlarmDigitLabels]; + + [dateFormatter release]; + + // [lcdImageView release]; + // [lcd release]; + + } else if ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] intValue] == 1) + { + cell.tag = kShowMapCell; + if (((NSArray *)[[NSUserDefaults standardUserDefaults] objectForKey:kLocationPoints]).count > 0) + { + [cell.textLabel setText:@"Show on Map"]; + } else { + [cell.textLabel setText:@"Set Place"]; + } + + + UIImage *disclosure = [UIImage imageNamed:@"disclosure-iPad.png"]; + UIImageView *disclosureImageView = [[UIImageView alloc] initWithFrame:CGRectMake(250.0, ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(disclosure.size.height/2), disclosure.size.width, disclosure.size.height)]; + [disclosureImageView setImage:disclosure]; + [disclosureImageView setOpaque:NO]; + [cell.contentView addSubview:disclosureImageView]; + + [disclosureImageView release]; + // [disclosure release]; + } + + break; + } + + case 3: { // this is for the "alarm on" switch. + + [cell.textLabel setText:@"Alarm On"]; + + alarmSwitch = [AlarmSettingsViewController createSwitch]; + CGRect newRect = alarmSwitch.frame; + newRect.origin.y = ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(newRect.size.height/2); + alarmSwitch.frame = newRect; + + [alarmSwitch addTarget:self action:@selector(switchFlipped:) forControlEvents:UIControlEventValueChanged]; + [alarmSwitch setOn:[[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue] animated:YES]; + alarmSwitch.tag = kAlarmSwitch; + [cell.contentView addSubview:alarmSwitch]; + + break; + } + case 4: { + // this is for the voice controls switch. + + [cell.textLabel setText:@"Voice Controls"]; + + UIImage *offIndicatorImage; + UIImage *onIndicatorImage; + +// if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) +// { + offIndicatorImage = [UIImage imageNamed:@"indicatorLightOff-iPad.png"]; + onIndicatorImage = [UIImage imageNamed:@"indicatorLightOn-iPad.png"]; +// } else { +// offIndicatorImage = [UIImage imageNamed:@"indicatorLightOff.png"]; +// onIndicatorImage = [UIImage imageNamed:@"indicatorLightOn.png"]; +// } + + UIImageView *offIndicatorImageView = [[UIImageView alloc] initWithFrame:CGRectMake(190.0, ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(offIndicatorImage.size.height/2), offIndicatorImage.size.width, offIndicatorImage.size.height)]; + offIndicatorImageView.tag = VC_OFFINDICATORIMAGE_TAG; + [offIndicatorImageView setOpaque:NO]; + [offIndicatorImageView setImage:offIndicatorImage]; + + UIImageView *onIndicatorImageView = [[UIImageView alloc] initWithFrame:CGRectMake(190.0, ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(onIndicatorImage.size.height/2), onIndicatorImage.size.width, onIndicatorImage.size.height)]; + onIndicatorImageView.tag = VC_ONINDICATORIMAGE_TAG; + [onIndicatorImageView setOpaque:NO]; + [onIndicatorImageView setImage:onIndicatorImage]; + + //if ([[[NSUserDefaults standardUserDefaults] objectForKey:kEnableVoiceControls] boolValue]) { + if (indicatorLightWasOn) { + // indicatorImage = [UIImage imageNamed:@"indicatorLightOn-iPad.png"]; + offIndicatorImageView.alpha = 0.0; + onIndicatorImageView.alpha = 1.0; + } else { + // indicatorImage = [UIImage imageNamed:@"indicatorLightOff-iPad.png"]; + offIndicatorImageView.alpha = 1.0; + onIndicatorImageView.alpha = 0.0; + } + + [cell.contentView addSubview:offIndicatorImageView]; + [cell.contentView addSubview:onIndicatorImageView]; + [offIndicatorImageView release]; + [onIndicatorImageView release]; + + UIImage *disclosure; + // if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) +// { + disclosure = [UIImage imageNamed:@"disclosure-iPad.png"]; +// } else { +// disclosure = [UIImage imageNamed:@"disclosure.png"]; +// } + UIImageView *disclosureImageView = [[UIImageView alloc] initWithFrame:CGRectMake(250.0, ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(disclosure.size.height/2), disclosure.size.width, disclosure.size.height)]; + [disclosureImageView setImage:disclosure]; + [disclosureImageView setOpaque:NO]; + [cell.contentView addSubview:disclosureImageView]; + + [disclosureImageView release]; + + break; + } + case 5: // this is for the Snooze setting. + { + [cell.textLabel setText:@"Snooze Minutes"]; + + UIImage *blackScreen = [UIImage imageNamed:@"blackScreen.png"]; + UIImageView *borderImageView = [[UIImageView alloc] initWithFrame:CGRectMake(195.0, ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(blackScreen.size.height/2), blackScreen.size.width, blackScreen.size.height)]; + [borderImageView setImage:blackScreen]; + [cell.contentView addSubview:borderImageView]; + + ShadowedLabel *snoozeTimeLabel = [[ShadowedLabel alloc] initWithFrame:CGRectMake(borderImageView.frame.origin.x+borderImageView.frame.size.width/2-100.0/2, ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(27.0/2), 100.0, 27.0)]; + snoozeTimeLabel.textAlignment = UITextAlignmentCenter; + snoozeTimeLabel.font = [UIFont boldSystemFontOfSize:12.0]; + snoozeTimeLabel.textColor = [UIColor colorWithRed:.72 green:.91 blue:1.0 alpha:1.0]; + snoozeTimeLabel.shadowColor = [UIColor colorWithRed:0.0 green:.52 blue:1.0 alpha:.9]; + snoozeTimeLabel.shadowBlur = 10.0; + snoozeTimeLabel.backgroundColor = [UIColor clearColor]; + [snoozeTimeLabel setText:[[[NSUserDefaults standardUserDefaults] objectForKey:kSnoozeMinutes] stringValue]]; + snoozeTimeLabel.tag = SNOOZE_TIME_LABEL_TAG; + [cell.contentView addSubview:snoozeTimeLabel]; + + [snoozeTimeLabel release]; + [borderImageView release]; + + break; + } + case 6: // this is for the Dynamite Mode switch. + { + [cell.textLabel setText:@"Dynamite Mode!"]; + cell.tag = DYNAMITE_CELL; + + CustomUISwitch *dynamiteSwitch = [AlarmSettingsViewController createSwitch]; + CGRect newRect = dynamiteSwitch.frame; + newRect.origin.y = ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(newRect.size.height/2); + dynamiteSwitch.frame = newRect; + + [dynamiteSwitch addTarget:self action:@selector(switchFlipped:) forControlEvents:UIControlEventValueChanged]; + + [dynamiteSwitch setOn:[[[NSUserDefaults standardUserDefaults] objectForKey:kEnableDynamiteMode] boolValue] animated:YES]; + dynamiteSwitch.tag = kDynamiteSwitch; + + [cell.contentView addSubview:dynamiteSwitch]; + + + break; + } + + case 8: + { + // this is for the music picker. + self.musicCell = cell; + [self setLabelInMusicCell]; + + UIImage *disclosure; + // if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + // { + disclosure = [UIImage imageNamed:@"disclosure-iPad.png"]; + // } else { + // disclosure = [UIImage imageNamed:@"disclosure.png"]; + // } + UIImageView *disclosureImageView = [[UIImageView alloc] initWithFrame:CGRectMake(250.0, ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(disclosure.size.height/2), disclosure.size.width, disclosure.size.height)]; + [disclosureImageView setImage:disclosure]; + [disclosureImageView setOpaque:NO]; + [cell.contentView addSubview:disclosureImageView]; + + [disclosureImageView release]; + // [disclosure release]; + + break; + } + + case 9: // this is for the "shuffle switch. + { + [cell.textLabel setText:@"Shuffle"]; + + CustomUISwitch *shuffleSwitch = [AlarmSettingsViewController createSwitch]; + CGRect newRect = shuffleSwitch.frame; + newRect.origin.y = ([self tableView:tableView heightForRowAtIndexPath:indexPath]/2)-(newRect.size.height/2); + shuffleSwitch.frame = newRect; + + [shuffleSwitch addTarget:self action:@selector(switchFlipped:) forControlEvents:UIControlEventValueChanged]; + [shuffleSwitch setOn:[[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMusicShuffle] boolValue] animated:YES]; + shuffleSwitch.tag = kShuffleSwitch; + + [cell.contentView addSubview:shuffleSwitch]; + + break; + } + + default: + break; + + + } + + UIImage *rowBackground; + UIImage *selectionBackground; + NSInteger row = [indexPath row]; +// NSInteger section = [indexPath section]; + + NSString *backgroundImageName = @""; + NSString *selectedBackgroundImageName = @""; + +/* if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { +*/ + if (row < [self tableView:tableView numberOfRowsInSection:0]-1) + { + if (row == 1) + { + backgroundImageName = @"lightRowTop.png"; + selectedBackgroundImageName = @"lightRowTop.png"; + } else if (row != 0) + { + backgroundImageName = @"lightRow.png"; + selectedBackgroundImageName = @"lightRow.png"; + } + } + rowBackground = [UIImage imageNamed:backgroundImageName]; + selectionBackground = [UIImage imageNamed:selectedBackgroundImageName]; + + UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectZero]; + UIImageView *selectedBackgroundImageView = [[UIImageView alloc] initWithFrame:CGRectZero]; + backgroundImageView.image = rowBackground; + selectedBackgroundImageView.image = selectionBackground; + + cell.backgroundView = backgroundImageView; + cell.selectedBackgroundView = selectedBackgroundImageView; + + [backgroundImageView release]; + [selectedBackgroundImageView release]; + +// [rowBackground release]; +// [selectionBackground release]; + + return cell; +} + +- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [aTableView deselectRowAtIndexPath:indexPath animated:YES]; +} + +- (NSIndexPath *)tableView:(UITableView *)aTableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { + + switch (indexPath.row) { + + case 1: + { + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] intValue] == 0) { + // "Alarm Time" tapped; bring up the datepicker to set the alarm time. + [self toggleDatePicker:self]; + } else if ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] intValue] == 1) { + [self pushMapView:self]; + } + break; + } + case 4: + { + // "Voice Controls" button tapped; go the the voice settings screen. + + UInt32 inputAvailableSize = sizeof(UInt32); + UInt32 inputAvailable; + AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &inputAvailableSize, &inputAvailable); + if (inputAvailable) + { + [self pushVoiceControls:self]; + } else { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Voice Controls not available" + message:@"You must have a microphone connected to use Voice Controls." + delegate:self + cancelButtonTitle:@"OK" + otherButtonTitles:nil, nil]; + [alert show]; + [alert release]; + } + break; + } + + case 5: + { + [self toggleKeypad:[tableView cellForRowAtIndexPath:indexPath]]; + break; + } + case 8: + { + // "Music" button tapped; bring up the music picker. + [self chooseMusic:self]; + break; + } + + + default: + break; + } + + return indexPath; +} + +- (UIButton *) getDetailDiscolosureIndicatorForIndexPath: (NSIndexPath *) indexPath +{ + UIButton *button = [UIButton buttonWithType: UIButtonTypeDetailDisclosure]; + button.frame = CGRectMake(320.0 - 44.0, 0.0, 44.0, 44.0); + [button addTarget:self action:@selector(AddMusicOrShowMusic:) forControlEvents:UIControlEventTouchUpInside]; + return button; +} + +- (void) detailDiscolosureIndicatorSelected: (UIButton *) sender +{ + // + // Obtain a reference to the selected cell + // + + // + // Do something like render a detailed view + // +} + + +/*- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + //NSInteger row = [indexPath row]; + + // create a UIButton (UIButtonTypeDetailDisclosure) + UIButton *detailDisclosureButtonType = [[UIButton buttonWithType:UIButtonTypeDetailDisclosure] retain]; + detailDisclosureButtonType.frame = CGRectMake(0.0, 0.0, 25.0, 25.0); + [detailDisclosureButtonType setTitle:@"Detail Disclosure" forState:UIControlStateNormal]; + detailDisclosureButtonType.backgroundColor = [UIColor clearColor]; + [detailDisclosureButtonType addTarget:self action:@selector(action:) forControlEvents:UIControlEventTouchUpInside]; + + UITableViewCell *cell = [self obtainTableCellForRow:0]; + + // this cell hosts the rounded button + ((DisplayCell *)cell).nameLabel.text = @"Detail Disclosure"; + ((DisplayCell *)cell).view = detailDisclosureButtonType; + + + + switch (indexPath.section) + { + case kUIGrayButton_Section: + { + if (row == 0) + { + // this cell hosts the gray button + ((DisplayCell *)cell).nameLabel.text = @"Background Image"; + ((DisplayCell *)cell).view = grayButton; + } + else + { + // this cell hosts the info on where to find the code + ((SourceCell *)cell).sourceLabel.text = @"ButtonsViewController.m - createGrayButton"; + } + break; + } + + case kUIImageButton_Section: + { + if (row == 0) + { + // this cell hosts the button with image + ((DisplayCell *)cell).nameLabel.text = @"Button with Image"; + ((DisplayCell *)cell).view = imageButton; + } + else + { + // this cell hosts the info on where to find the code + ((SourceCell *)cell).sourceLabel.text = @"ButtonsViewController.m - createImageButton"; + } + break; + } + + case kUIRoundRectButton_Section: + { + if (row == 0) + { + // this cell hosts the rounded button + ((DisplayCell *)cell).nameLabel.text = @"Rounded Button"; + ((DisplayCell *)cell).view = roundedButtonType; + } + else + { + // this cell hosts the info on where to find the code + ((SourceCell *)cell).sourceLabel.text = @"ButtonsViewController.m - createRoundedButton"; + } + break; + } + + case kUIDetailDisclosureButton_Section: + { + if (row == 0) + { + // this cell hosts the rounded button + ((DisplayCell *)cell).nameLabel.text = @"Detail Disclosure"; + ((DisplayCell *)cell).view = detailDisclosureButtonType; + } + else + { + // this cell hosts the info on where to find the code + ((SourceCell *)cell).sourceLabel.text = @"ButtonsViewController.m - createDetailDisclosureButton"; + } + break; + } + + case kUIInfoLightButton_Section: + { + if (row == 0) + { + // this cell hosts the rounded button + ((DisplayCell *)cell).nameLabel.text = @"Info Light"; + ((DisplayCell *)cell).view = infoLightButtonType; + } + else + { + // this cell hosts the info on where to find the code + ((SourceCell *)cell).sourceLabel.text = @"ButtonsViewController.m - createInfoLightButton"; + } + break; + } + + case kUIInfoDarkButton_Section: + { + if (row == 0) + { + // this cell hosts the rounded button + ((DisplayCell *)cell).nameLabel.text = @"Info Dark"; + ((DisplayCell *)cell).view = infoDarkButtonType; + } + else + { + // this cell hosts the info on where to find the code + ((SourceCell *)cell).sourceLabel.text = @"ButtonsViewController.m - createInfoDarkButton"; + } + break; + } + + case kUIContactAddButton_Section: + { + if (row == 0) + { + // this cell hosts the rounded button + ((DisplayCell *)cell).nameLabel.text = @"Contact Add"; + ((DisplayCell *)cell).view = contactAddButtonType; + } + else + { + // this cell hosts the info on where to find the code + ((SourceCell *)cell).sourceLabel.text = @"ButtonsViewController.m - createContactAddButton"; + } + break; + } + } + + return cell; +}*/ + +/*- (UITableViewCell *)obtainTableCellForRow:(NSInteger)row +{ + UITableViewCell *cell = nil; + + if (row == 0) + cell = [tableView dequeueReusableCellWithIdentifier:kDisplayCell_ID]; + else if (row == 1) + cell = [tableView dequeueReusableCellWithIdentifier:kSourceCell_ID]; + + if (cell == nil) + { + if (row == 0) + cell = [[[DisplayCell alloc] initWithFrame:CGRectZero reuseIdentifier:kDisplayCell_ID] autorelease]; + else if (row == 1) + cell = [[[SourceCell alloc] initWithFrame:CGRectZero reuseIdentifier:kSourceCell_ID] autorelease]; + } + + return [tableView dequeueReusableCellWithIdentifier:kDisplayCell_ID]; +}*/ + +@end diff --git a/Classes/BlackSegmentedControl.h b/Classes/BlackSegmentedControl.h new file mode 100644 index 0000000..3815bce --- /dev/null +++ b/Classes/BlackSegmentedControl.h @@ -0,0 +1,16 @@ +// +// BlackSegmentedControl.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 4/21/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import + + +@interface BlackSegmentedControl : UISegmentedControl { + +} + +@end diff --git a/Classes/BlackSegmentedControl.m b/Classes/BlackSegmentedControl.m new file mode 100644 index 0000000..6eea596 --- /dev/null +++ b/Classes/BlackSegmentedControl.m @@ -0,0 +1,43 @@ +// +// BlackSegmentedControl.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 4/21/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "BlackSegmentedControl.h" + + +@implementation BlackSegmentedControl + + +- (id)initWithItems:(NSArray *)items +{ + self = [super initWithItems:items]; + + return self; +} + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + + return self; +} + + +// Only override drawRect: if you perform custom drawing. +// An empty implementation adversely affects performance during animation. +- (void)drawRect:(CGRect)rect { +} + + + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/Classes/Constants.h b/Classes/Constants.h new file mode 100644 index 0000000..c8feff2 --- /dev/null +++ b/Classes/Constants.h @@ -0,0 +1,38 @@ +// +// Constants.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 6/20/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import + +#define kAlarmOn @"AlarmOn" +#define kAlarmDate @"AlarmDate" +#define kAlarmMode @"AlarmMode" +#define kEnableVoiceControls @"EnableVoiceControls" +#define kAlarmMusicShuffle @"AlarmMusicShuffle" +#define kSleepTimerMusicShuffle @"MusicShuffle" +#define kAlarmSongsCollection @"AlarmSongsCollection" +#define kSleepTimerSongsCollection @"SleepTimerSongsCollection" +#define kEnableDynamiteMode @"EnableDynamiteMode" +#define kAlarmPlayInterval @"AlarmPlayInterval" +#define kAlarmPauseInterval @"AlarmPauseInterval" +#define kVoiceFunction @"VoiceFunction" +#define kSnoozeMinutes @"SnoozeMinutes" +#define kSleepTimerFunction @"SleepTimerFunction" +#define kSleepTimerSeconds @"SleepTimerSeconds" +#define kLocationPoints @"LocationPoints" +#define kHasShownDrawingMessage @"HasShownDrawingMessage" +#define kHasShownChargingMessage @"HasShownChargingMessage" +#define kHasShownBrightnessMessage @"HasShownBrightnessMessage" +#define kHasShownBackgroundMessage @"HasShownBackgroundMessage" +#define kOldTimeZone @"OldTimeZone" + +#define LEFT_BUTTON_SEGMENT 2000 +#define RIGHT_BUTTON_SEGMENT 2001 + +#define KEYPAD_HEIGHT_MINUS_SHADOW keypadViewFrame.size.height - 20 +#define BOTTOMBAR_HEIGHT 49 +#define MENUBAR_HEIGHT 20 diff --git a/Classes/CustomUISwitch.h b/Classes/CustomUISwitch.h new file mode 100755 index 0000000..739f4ba --- /dev/null +++ b/Classes/CustomUISwitch.h @@ -0,0 +1,40 @@ +// +// CustomUISwitch.h +// +// Created by Duane Homick +// Homick Enterprises - www.homick.com +// +// The CustomUISwitch can be used the same way a UISwitch can, but using the PSD attached, you can create your own color scheme. + +#import + +@protocol CustomUISwitchDelegate; + +@interface CustomUISwitch : UIControl +{ + id _delegate; + BOOL _on; + BOOL useLightGraphics; + + NSInteger _hitCount; + UIImageView* _backgroundImage; + UIImageView* _switchImage; +} + +@property (nonatomic, assign, readwrite) id delegate; + +//- (id)initWithFrame:(CGRect)frame; // This class enforces a size appropriate for the control. The frame size is ignored. +- (id)initWithFrame:(CGRect)frame lighter:(BOOL)lighter; + +- (void)setOn:(BOOL)on animated:(BOOL)animated; // does not send action +- (BOOL)isOn; + +@end + +@protocol CustomUISwitchDelegate + +@optional +- (void)valueChangedInView:(CustomUISwitch*)view; + +@end + diff --git a/Classes/CustomUISwitch.m b/Classes/CustomUISwitch.m new file mode 100755 index 0000000..c71ec62 --- /dev/null +++ b/Classes/CustomUISwitch.m @@ -0,0 +1,235 @@ +// +// CustomUISwitch.m +// +// Created by Duane Homick +// Homick Enterprises - www.homick.com +// + +#import "CustomUISwitch.h" + +#define SWITCH_DISPLAY_WIDTH 94.0 +#define SWITCH_WIDTH 149.0 +#define SWITCH_HEIGHT 27.0 + +#define RECT_FOR_OFF CGRectMake(-55.0, 0.0, SWITCH_WIDTH, SWITCH_HEIGHT) +#define RECT_FOR_ON CGRectMake(0.0, 0.0, SWITCH_WIDTH, SWITCH_HEIGHT) +#define RECT_FOR_HALFWAY CGRectMake(-27.5, 0.0, SWITCH_WIDTH, SWITCH_HEIGHT) + +@interface CustomUISwitch () +@property (nonatomic, retain, readwrite) UIImageView* backgroundImage; +@property (nonatomic, retain, readwrite) UIImageView* switchImage; +- (void)setupUserInterface; +- (void)toggle; +- (void)animateSwitch:(BOOL)toOn; +@end + + +@implementation CustomUISwitch +@synthesize backgroundImage = _backgroundImage; +@synthesize switchImage = _switchImage; +@synthesize delegate = _delegate; + +/** + * Destructor + */ +- (void)dealloc +{ + [_backgroundImage release]; + [_switchImage release]; + [super dealloc]; +} + +/** + * Constructor + */ +- (id)initWithFrame:(CGRect)frame lighter:(BOOL)lighter +{ + if (self = [super initWithFrame:CGRectMake(frame.origin.x, frame.origin.y, SWITCH_DISPLAY_WIDTH, SWITCH_HEIGHT)]) + { + _on = YES; + _hitCount = 0; + useLightGraphics = lighter; + + self.backgroundColor = [UIColor clearColor]; + self.clipsToBounds = YES; + self.autoresizesSubviews = NO; + self.autoresizingMask = 0; + self.opaque = YES; + + [self setupUserInterface]; + } + return self; +} + +/** + * Setup the user interface + */ +- (void)setupUserInterface +{ + // Background image + UIImageView* bg = [[UIImageView alloc] initWithFrame:RECT_FOR_ON]; + if (useLightGraphics) { + bg.image = [UIImage imageNamed:@"switch_on_lighter.png"]; + } else { + bg.image = [UIImage imageNamed:@"switch_on.png"]; + } + bg.backgroundColor = [UIColor clearColor]; + bg.contentMode = UIViewContentModeLeft; + self.backgroundImage = bg; + [bg release]; + + // Switch image + UIImageView* foreground = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, SWITCH_WIDTH, SWITCH_HEIGHT)]; + + if (useLightGraphics) { + foreground.image = [UIImage imageNamed:@"switch_lighter.png"]; + } else { + foreground.image = [UIImage imageNamed:@"switch.png"]; + } + foreground.contentMode = UIViewContentModeLeft; + self.switchImage = foreground; + [foreground release]; + + // Check for user input + [self addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; + + [self addSubview:self.backgroundImage]; + [self.backgroundImage addSubview:self.switchImage]; +} + +/** + * Drawing Code + */ +- (void)drawRect:(CGRect)rect +{ + // nothing +} + +/** + * Configure it into a certain state + */ +- (void)setOn:(BOOL)on animated:(BOOL)animated +{ + _on = on; + [self sendActionsForControlEvents:UIControlEventValueChanged]; + + if (_on) + { + self.switchImage.frame = RECT_FOR_ON; + if (useLightGraphics) { + self.backgroundImage.image = [UIImage imageNamed:@"switch_on_lighter.png"]; + } else { + self.backgroundImage.image = [UIImage imageNamed:@"switch_on.png"]; + } + } + else + { + self.switchImage.frame = RECT_FOR_OFF; + if (useLightGraphics) { + self.backgroundImage.image = [UIImage imageNamed:@"switch_off_lighter.png"]; + } else { + self.backgroundImage.image = [UIImage imageNamed:@"switch_off.png"]; + } + + } +} + +/** + * Check if on + */ +- (BOOL)isOn +{ + return _on; +} + +/** + * Capture user input + */ +- (void)buttonPressed:(id)target +{ + // We use a hit count to properly queue up multiple hits on the button while we are animating. + if (_hitCount == 0) + { + _hitCount++; + [self toggle]; + } + else + { + _hitCount++; + // Do not animate, this will happen when other animation finishes + } +} + +/** + * Toggle ison + */ +- (void)toggle +{ + _on = !_on; + [self sendActionsForControlEvents:UIControlEventValueChanged]; + + [self animateSwitch:_on]; + +} + +/** + * Animate the switch by sliding halfway and then changing the background image and then sliding the rest of the way. + */ +- (void)animateSwitch:(BOOL)toOn +{ + [UIView beginAnimations:nil context:nil]; + [UIView setAnimationDuration:0.1]; + + self.switchImage.frame = RECT_FOR_HALFWAY; + + [UIView beginAnimations:nil context:nil]; + [UIView setAnimationDuration:0.1]; + [UIView setAnimationDelegate:self]; + [UIView setAnimationDidStopSelector:@selector(animationHasFinished:finished:context:)]; + + if (toOn) + { + self.switchImage.frame = RECT_FOR_ON; + if (useLightGraphics) { + self.backgroundImage.image = [UIImage imageNamed:@"switch_on_lighter.png"]; + } else { + self.backgroundImage.image = [UIImage imageNamed:@"switch_on.png"]; + } + } + else + { + self.switchImage.frame = RECT_FOR_OFF; + if (useLightGraphics) { + self.backgroundImage.image = [UIImage imageNamed:@"switch_off_lighter.png"]; + } else { + self.backgroundImage.image = [UIImage imageNamed:@"switch_off.png"]; + } + } + [UIView commitAnimations]; + + [UIView commitAnimations]; +} + +/** + * Remove the view no longer visible + */ +- (void)animationHasFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context +{ + if (_delegate) + { + [_delegate valueChangedInView:self]; + } + + // We use a hit count to properly queue up multiple hits on the button while we are animating. + if (_hitCount > 1) + { + _hitCount--; + [self toggle]; + } + else + { + _hitCount--; + } +} + +@end \ No newline at end of file diff --git a/Classes/EmptyViewController.h b/Classes/EmptyViewController.h new file mode 100644 index 0000000..b5e3ee1 --- /dev/null +++ b/Classes/EmptyViewController.h @@ -0,0 +1,16 @@ +// +// EmptyViewController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 9/9/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import + + +@interface EmptyViewController : UIViewController { + +} + +@end diff --git a/Classes/EmptyViewController.m b/Classes/EmptyViewController.m new file mode 100644 index 0000000..21f4a29 --- /dev/null +++ b/Classes/EmptyViewController.m @@ -0,0 +1,64 @@ + // +// EmptyViewController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 9/9/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "EmptyViewController.h" + + +@implementation EmptyViewController + +- (id)init +{ + self = [super init]; + + self.view = [[UIView alloc] initWithFrame:CGRectMake(-50, -50, 350, 500)]; + self.view.backgroundColor = [UIColor whiteColor]; + + return self; +} + +/* +// Implement loadView to create a view hierarchy programmatically, without using a nib. +- (void)loadView { +} +*/ + +/* +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad { + [super viewDidLoad]; +} +*/ + +/* +// Override to allow orientations other than the default portrait orientation. +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations + return (interfaceOrientation == UIInterfaceOrientationPortrait); +} +*/ + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + [super viewDidUnload]; + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/Classes/FirstViewController.h b/Classes/FirstViewController.h new file mode 100644 index 0000000..aa31d3e --- /dev/null +++ b/Classes/FirstViewController.h @@ -0,0 +1,36 @@ +// +// FirstViewController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 6/9/09. +// Copyright The Byte Factory 2009. All rights reserved. +// + +#import + +@interface FirstViewController : UIViewController { + + IBOutlet UILabel *currentTimeLabel; + IBOutlet UILabel *currentDateLabel; + IBOutlet UIWindow *window; + +// NSTimer *timer; +// NSTimer *listenerTimer; +} + +@property (nonatomic, retain) UILabel *currentTimeLabel; +@property (nonatomic, retain) UILabel *currentDateLabel; +//@property (nonatomic, retain) NSTimer *timer; + + +//- (IBAction)setupAlarm:(id)sender; +//- (IBAction)stopAlarm:(id)sender; +//- (IBAction)setAlarmOnValue:(id)sender; +//- (IBAction)showNightView:(id)sender; +- (void)setCurrentDateAndTimeLabels; +//- (void)processVolumeReading:(NSNumber *)volumeLevel; + +//- (void)alarmDidStartRinging; + + +@end diff --git a/Classes/FirstViewController.m b/Classes/FirstViewController.m new file mode 100644 index 0000000..d67f528 --- /dev/null +++ b/Classes/FirstViewController.m @@ -0,0 +1,367 @@ +// +// FirstViewController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 6/9/09. +// Copyright The Byte Factory 2009. All rights reserved. +// + +#import +#import "Constants.h" +#import "FirstViewController.h" +#import +#import +#import "SCListener.h" +#import "AlarmRingingViewController.h" +#import "AlarmController.h" +#import "Sleep_Blaster_touchAppDelegate.h" + +@implementation FirstViewController + +@synthesize currentTimeLabel; +@synthesize currentDateLabel; +//@synthesize timer; + +//BOOL alarmIsRinging = NO; + + +/* +// The designated initializer. Override to perform setup that is required before the view is loaded. +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + // Custom initialization + } + return self; +} +*/ + +/* +// Implement loadView to create a view hierarchy programmatically, without using a nib. +- (void)loadView { +} +*/ + +/* + NSUInteger loadFonts() +{ + NSUInteger newFontCount = 0; + NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"com.apple.GraphicsServices"]; + const char *frameworkPath = [[frameworkBundle executablePath] UTF8String]; + if (frameworkPath) { + void *graphicsServices = dlopen(frameworkPath, RTLD_NOLOAD | RTLD_LAZY); + if (graphicsServices) { + BOOL (*GSFontAddFromFile)(const char *) = dlsym(graphicsServices, "GSFontAddFromFile"); + if (GSFontAddFromFile) + for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:nil]) + newFontCount += GSFontAddFromFile([fontFile UTF8String]); + } + } + return newFontCount; +} +*/ + +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad { + [super viewDidLoad]; + + loadFonts(); + + UIFont *bigFont = [UIFont fontWithName:@"Digital-7" size:80.0]; + UIFont *smallFont = [UIFont fontWithName:@"Digital-7" size:24.0]; + + currentTimeLabel.font = bigFont; + currentDateLabel.font = smallFont; + + [self setCurrentDateAndTimeLabels]; + +// [AlarmController sharedAlarmController].alarmInterfaceDelegate = self; + + NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:2 target:self + selector:@selector(updateClock:) + userInfo:nil repeats:YES]; + + +// [alarmOnSwitch setOn:[[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue]]; + + + //AlarmRingingViewController *alarmRingingViewController = [[AlarmRingingViewController alloc] initWithNibName:@"AlarmRingingView" bundle:[NSBundle mainBundle]]; + + + [[AlarmController sharedAlarmController] setupAlarm:self]; +} + +- (void)viewDidAppear:(BOOL)animated +{ + + [UIDevice currentDevice].proximityMonitoringEnabled = YES; + + // We're loading the alarm songs collection right after the app launched + // so that we won't have to do it later, because it might take a few seconds. We're storing it + // in the app delegate so that the SecondView can access it too. +// Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; +// mainDelegate.songsCollection = [NSKeyedUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] objectForKey:kSongsCollection]]; +} + +- (void)viewWillDisappear:(BOOL)animated +{ + [UIDevice currentDevice].proximityMonitoringEnabled = NO; +} + + +- (void)updateClock:(NSTimer *)theTimer +{ + [self setCurrentDateAndTimeLabels]; +} + +- (void)setCurrentDateAndTimeLabels +{ + NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; + [dateFormatter setDateFormat:@"h:mma"]; + NSString *currentTime = [dateFormatter stringFromDate:[NSDate date]]; + [currentTimeLabel setText:currentTime]; + + [dateFormatter setDateFormat:@"cccc, MMMM d"]; + NSString *currentDate = [dateFormatter stringFromDate:[NSDate date]]; + [currentDateLabel setText:currentDate]; + +} + +/* +- (IBAction)setupAlarm:(id)sender +{ +// if (timer) { +// // Either the user is changing the alarm time, or the user is turning off the alarm. +// // Either way, we need to disable the timer for now. +// [timer invalidate]; +// } + + if ([sender class] == [UISwitch class]) { + [self setAlarmOnValue:sender]; + } + + [[AlarmController sharedAlarmController] setupAlarm:self]; + +// if (![[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue]) { +// return; +// } +// +// NSDate *alarmDate = [[NSUserDefaults standardUserDefaults] objectForKey:kAlarmDate]; +// if (!alarmDate) { +// return; +// } +// +// //[[NSUserDefaults standardUserDefaults] setObject:alarmDate forKey:kAlarmDate]; // update the date in the alarmSettings dictionary with the REAL alarm time/date. +// +// timer = [[[NSTimer alloc] initWithFireDate:alarmDate +// interval:0 +// target:self +// selector:@selector(timerDidFire:) +// userInfo:nil +// repeats:NO] retain]; +// [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode]; +// +// NSLog(@"You will wake up at %@", alarmDate); +} +*/ + +//- (IBAction)setAlarmOnValue:(UISwitch *)sender +//{ +// [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:sender.on] forKey:kAlarmOn]; +// [[AlarmController sharedAlarmController] setupAlarm:self]; +//} + +/*- (IBAction)stopAlarm:(id)sender +{ +// if (usingAlarmMode == ITUNES) { + [[MPMusicPlayerController applicationMusicPlayer] stop]; +// } else if (usingAlarmMode == DYNAMITE) { +// [explosion stop]; +// [alarmSound stop]; +// [self toggleBlastWindow]; +// } + +// [self toggleAlarmRingingView]; + +// alarmIsRinging = NO; + + // If the alarm is set to go off on weekdays, we need to set the timer again. + [self setupAlarm:self]; +}*/ + + + +//- (void)timerDidFire:(NSTimer *)theTimer +//{ +//// NSLog(@"the timer is firing!"); +//// +//// alarmIsRinging = YES; +//// +////// if ([sleepTimerView superview]) { // if the sleep timer is going on... +////// [self stopSleepTimer:self]; // stop it before ringing the alarm. +////// } +//// +////// // If it's set for one date, turn it off now. +////// if ([[alarmSettings objectForKey:@"AlarmDays"] count] == 0) { +//// [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:NO] forKey:kAlarmOn]; +// [alarmOnSwitch setOn:NO animated:YES]; +// +//// } +// +//// // Set the system volume. +//// NSMutableString *scriptSource = [NSMutableString stringWithFormat:@"set volume %d\n", [[userDef objectForKey:@"SystemVolume"] intValue]]; +//// NSAppleScript *setSysetmVolume = [[[NSAppleScript alloc] initWithSource:scriptSource] autorelease]; +//// NSDictionary *error = [NSDictionary dictionary]; +//// [setSysetmVolume executeAndReturnError:&error]; +// +// +// //if ([[alarmSettings objectForKey:@"WakeupMode"] intValue] == 0) { // if it's set for iTunes... +// //usingAlarmMode = ITUNES; +// +// //[HUDView setDisplayMode:ITUNES]; +// +// //iTunesTrack *track = [self getiTunesTrackFromSettingsFor:SLEEP_BLASTER]; +// +// // Fade in the iTunes volume for the amount of time set. +// //[NSThread detachNewThreadSelector:@selector(graduallyIncreaseiTunesVolumeForSeconds:) toTarget:self +// // withObject:[userDef objectForKey:@"TimeToIncreaseAlarmVolume"]]; +// //[track playOnce:NO]; +// +//// MPMusicPlayerController *musicPlayerController = [MPMusicPlayerController applicationMusicPlayer]; +//// MPMediaItemCollection *mediaItemCollection = [NSKeyedUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] objectForKey:@"songs"]]; +//// +//// [musicPlayerController setVolume:1.0]; +//// [musicPlayerController setQueueWithItemCollection:mediaItemCollection]; +//// [musicPlayerController play]; +//// +//// // Only enable voice controls if it's using iTunes, and not Dynamite. +////// if ([[userDef objectForKey:@"SpeechControlsEnabled"] boolValue] == YES && +////// [[userDef objectForKey:@"TimeToIncreaseAlarmVolume"] intValue] == 0) { +//// +//// +//// if ([[[NSUserDefaults standardUserDefaults] objectForKey:kEnableVoiceControls] boolValue]) { +//// [NSThread detachNewThreadSelector:@selector(playAndPauseiTunes:) toTarget:self withObject:nil]; +//// } +// +// +// +// // } else { // otherwise, use dynamite. +//// usingAlarmMode = DYNAMITE; +//// [HUDView setDisplayMode:DYNAMITE]; +//// [self toggleBlastWindow]; +// +//// [explosion play]; +//// } +// +// // Finally, update the interface to show that the alarm's ringing. +// //[self toggleAlarmRingingView]; +// +// //AlarmRingingViewController *ringingController = [[AlarmRingingViewController alloc] initWithNibName:@"AlarmRingingView" bundle:<#(NSBundle *)nibBundleOrNil#> +//} + + +// Override to allow orientations other than the default portrait orientation. +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations + return YES; +} + + +#pragma mark iTunes Stuff + +//- (void)playAndPauseiTunes:(id)sender +//{ +// NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; +// +// // Let iTunes play for 2 microseconds * one million, then stop iTunes. +// //usleep([[userDef objectForKey:@"AlarmPlayInterval"] intValue]*1000000); +// usleep(2*1000000); +// +// MPMusicPlayerController *musicPlayerController = [MPMusicPlayerController applicationMusicPlayer]; +// +// float rampVolume; +// for (rampVolume = musicPlayerController.volume; rampVolume >= 0; rampVolume -= .04) { +// [musicPlayerController setVolume:rampVolume]; +// /* pause 2/100th of a second (20,000 microseconds) between adjustments. */ +// usleep(20000); +// } +// +// // If the alarm is still ringing, listen for 2 seconds, then stop listening. +// if (alarmIsRinging) { +// [self performSelectorOnMainThread:@selector(startReadingVolume:) withObject:self waitUntilDone:YES]; +// //usleep([[userDef objectForKey:@"AlarmPauseInterval"] intValue]*1000000); +// usleep(2*1000000); +// [self performSelectorOnMainThread:@selector(stopReadingVolume:) withObject:self waitUntilDone:YES]; +// } +// +// // Fade the volume back in. (That DOESN'T mean iTunes is actually playing!) +// //int targetVolume = [[userDef objectForKey:@"iTunesVolume"] intValue]; +// int targetVolume = 1.0; +// for (rampVolume = musicPlayerController.volume; rampVolume <= targetVolume; rampVolume += .04) { +// [musicPlayerController setVolume:rampVolume]; +// /* pause 2/100th of a second (10,000 microseconds) between adjustments. */ +// usleep(20000); +// } +// +// [pool release]; +// +// if (alarmIsRinging) { +// [self playAndPauseiTunes:self]; +// } +//} + +/*- (void)startReadingVolume:(id)sender +{ + [[SCListener sharedListener] listen]; + + if (listenerTimer) { + [listenerTimer invalidate]; + } + + listenerTimer = [[NSTimer scheduledTimerWithTimeInterval:.1 + target:self + selector:@selector(processVolumeReading) + userInfo:nil + repeats:YES] retain]; +} + +- (void)stopReadingVolume:(id)sender +{ + [listenerTimer invalidate]; + [[SCListener sharedListener] pause]; +} + +//- (void)processVolumeReading:(double)volumeLevel +- (void)processVolumeReading +{ + NSLog(@"%f", [[SCListener sharedListener] averagePower]); + float threshold = .15; + float volumeLevel = [[SCListener sharedListener] averagePower]; + if (volumeLevel > threshold) { + // stop the alarm... + [self stopAlarm:self]; + } +// } else { +// [self performSelectorOnMainThread:@selector(stopReadingVolume:) withObject:self waitUntilDone:YES]; +// //[musicPlayerController play]; +// } +} +*/ + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + +@end diff --git a/Classes/Randomizer.h b/Classes/Randomizer.h new file mode 100644 index 0000000..57e74e7 --- /dev/null +++ b/Classes/Randomizer.h @@ -0,0 +1,16 @@ +// +// Randomizer.h +// Sleep Blaster +// +// Created by Eamon Ford on 10/14/06. +// Copyright 2006 The Byte Factory. All rights reserved. +// + +#import + + +@interface Randomizer : NSObject { + +} +- (int)randomWithMax:(int)max; +@end diff --git a/Classes/Randomizer.m b/Classes/Randomizer.m new file mode 100644 index 0000000..6ce324c --- /dev/null +++ b/Classes/Randomizer.m @@ -0,0 +1,28 @@ +// +// Randomizer.m +// Sleep Blaster +// +// Created by Eamon Ford on 10/14/06. +// Copyright 2006 The Byte Factory. All rights reserved. +// + +#import "Randomizer.h" + + +@implementation Randomizer + +- (int)randomWithMax:(int)max +{ + return (random() % max) + 1; +} + +- (id)init +{ + if (self = [super init]) { + // Seed the random number generator with the time + srandom(time(NULL)); + } + return self; +} + +@end diff --git a/Classes/SCListener.h b/Classes/SCListener.h new file mode 100755 index 0000000..da778f0 --- /dev/null +++ b/Classes/SCListener.h @@ -0,0 +1,32 @@ +// +// SCListener 1.0.1 +// http://github.com/stephencelis/sc_listener +// +// (c) 2009-* Stephen Celis, . +// Released under the MIT License. +// + +#import +#import +#import + +@interface SCListener : NSObject { + AudioQueueLevelMeterState *levels; + + AudioQueueRef queue; + AudioStreamBasicDescription format; + Float64 sampleRate; +} + ++ (SCListener *)sharedListener; + +- (void)listen; +- (BOOL)isListening; +- (void)pause; +- (void)stop; + +- (Float32)averagePower; +- (Float32)peakPower; +- (AudioQueueLevelMeterState *)levels; + +@end diff --git a/Classes/SCListener.m b/Classes/SCListener.m new file mode 100755 index 0000000..34f50a5 --- /dev/null +++ b/Classes/SCListener.m @@ -0,0 +1,231 @@ +// +// SCListener 1.0.1 +// http://github.com/stephencelis/sc_listener +// +// (c) 2009-* Stephen Celis, . +// Released under the MIT License. +// + +#import "SCListener.h" + +@interface SCListener (Private) + +- (void)updateLevels; +- (void)setupQueue; +- (void)setupFormat; +- (void)setupBuffers; +- (void)setupMetering; + +@end + +static SCListener *sharedListener = nil; + +static void listeningCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer, const AudioTimeStamp *inStartTime, UInt32 inNumberPacketsDescriptions, const AudioStreamPacketDescription *inPacketDescs) { + SCListener *listener = (SCListener *)inUserData; + if ([listener isListening]) + AudioQueueEnqueueBuffer(inAQ, inBuffer, 0, NULL); +} + +@implementation SCListener + ++ (SCListener *)sharedListener { + @synchronized(self) { + if (sharedListener == nil) + [[self alloc] init]; + } + + return sharedListener; +} + +- (void)dealloc { + [sharedListener stop]; + [super dealloc]; +} + +#pragma mark - +#pragma mark Listening + +- (void)listen { + if (queue == nil) + [self setupQueue]; + + AudioQueueStart(queue, NULL); +} + +- (void)pause { + if (![self isListening]) + return; + + AudioQueueStop(queue, true); +} + +- (void)stop { + if (queue == nil) + return; + + AudioQueueDispose(queue, true); + queue = nil; +} + +- (BOOL)isListening { + + if (queue == nil) + return NO; + + UInt32 isListening, ioDataSize = sizeof(UInt32); + OSStatus result = AudioQueueGetProperty(queue, kAudioQueueProperty_IsRunning, &isListening, &ioDataSize); + return (result != noErr) ? NO : isListening; +} + +#pragma mark - +#pragma mark Levels getters + +- (Float32)averagePower { + if (![self isListening]) + return 0.0; + + return [self levels][0].mAveragePower; +} + +- (Float32)peakPower { + if (![self isListening]) + return 0.0; + + return [self levels][0].mPeakPower; +} + +- (AudioQueueLevelMeterState *)levels { + if (![self isListening]) + return nil; + + [self updateLevels]; + return levels; +} + +- (void)updateLevels { + UInt32 ioDataSize = format.mChannelsPerFrame * sizeof(AudioQueueLevelMeterState); + AudioQueueGetProperty(queue, (AudioQueuePropertyID)kAudioQueueProperty_CurrentLevelMeter, levels, &ioDataSize); +} + +#pragma mark - +#pragma mark Setup + +- (void)setupQueue { + if (queue) + return; + + [self setupFormat]; + [self setupBuffers]; + AudioQueueNewInput(&format, listeningCallback, self, NULL, NULL, 0, &queue); + [self setupMetering]; + + UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord; + AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory); + + UInt32 property = 1; + AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(property), &property); + +// UInt32 routeSize = sizeof(CFStringRef); +// CFStringRef route; +// AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &routeSize, &route); +// if (![(NSString *)route isEqualToString:@"Headset"] && +// ![(NSString *)route isEqualToString:@"Headphone"] && +// ![(NSString *)route isEqualToString:@"HeadphonesAndMicrophone"] && +// ![(NSString *)route isEqualToString:@"HeadsetInOut"]) +// { + NSString *deviceType = [UIDevice currentDevice].model; + if(![deviceType isEqualToString:@"iPod Touch"]) + { + UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; + AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOverride), &audioRouteOverride); + } +// } + + AudioSessionSetActive(true); +} + +- (void)setupFormat { +#if TARGET_IPHONE_SIMULATOR + format.mSampleRate = 44100.0; +#else + + UInt32 ioDataSize = sizeof(sampleRate); + AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareSampleRate, &ioDataSize, &sampleRate); + format.mSampleRate = sampleRate; +#endif + format.mFormatID = kAudioFormatLinearPCM; + format.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; + format.mFramesPerPacket = format.mChannelsPerFrame = 1; + format.mBitsPerChannel = 16; + format.mBytesPerPacket = format.mBytesPerFrame = 2; +} + +- (void)setupBuffers { + AudioQueueBufferRef buffers[3]; + for (NSInteger i = 0; i < 3; ++i) { + AudioQueueAllocateBuffer(queue, 735, &buffers[i]); + AudioQueueEnqueueBuffer(queue, buffers[i], 0, NULL); + } +} + +- (void)setupMetering { + levels = (AudioQueueLevelMeterState *)calloc(sizeof(AudioQueueLevelMeterState), format.mChannelsPerFrame); + UInt32 trueValue = true; + AudioQueueSetProperty(queue, kAudioQueueProperty_EnableLevelMetering, &trueValue, sizeof(UInt32)); +} + +#pragma mark - +#pragma mark Singleton Pattern + ++ (id)allocWithZone:(NSZone *)zone { + @synchronized(self) { + if (sharedListener == nil) { + sharedListener = [super allocWithZone:zone]; + return sharedListener; + } + } + + return nil; +} + +- (id)copyWithZone:(NSZone *)zone { + return self; +} + +- (id)init { + if ([super init] == nil) + return nil; + + + AudioSessionInitialize (NULL, NULL, NULL, NULL); +// UInt32 category; +// UInt32 propertySize = sizeof(category); +// AudioSessionGetProperty(kAudioSessionProperty_AudioCategory, &propertySize, &category); +// +// if (category == kAudioSessionCategory_PlayAndRecord) { +// NSLog(@"it's set to the play and record category."); +// } else { +// NSLog(@"it's not set to the play and record category!"); +// } + + + return self; +} + +- (id)retain { + return self; +} + +- (unsigned)retainCount { + return UINT_MAX; +} + +- (void)release { + // Do nothing. +} + +- (id)autorelease { + return self; +} + +@end diff --git a/Classes/ShadowedLabel.h b/Classes/ShadowedLabel.h new file mode 100644 index 0000000..7ba2677 --- /dev/null +++ b/Classes/ShadowedLabel.h @@ -0,0 +1,20 @@ +// +// ShadowedLabel.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 11/29/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import + + +@interface ShadowedLabel : UILabel { + float shadowBlur; + UIColor *shadowColor; +} + +@property float shadowBlur; +@property (nonatomic, retain) UIColor *shadowColor; + +@end diff --git a/Classes/ShadowedLabel.m b/Classes/ShadowedLabel.m new file mode 100644 index 0000000..8905a4a --- /dev/null +++ b/Classes/ShadowedLabel.m @@ -0,0 +1,58 @@ +// +// ShadowedLabel.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 11/29/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import "ShadowedLabel.h" + + +@implementation ShadowedLabel + +@synthesize shadowBlur; +@synthesize shadowColor; + +- (void) drawTextInRect:(CGRect)rect { + + if (!shadowBlur) { + shadowBlur = 5.0; + } + + CGSize myShadowOffset = CGSizeMake(0, 0); + + if (!self.shadowColor) + { + self.shadowColor = self.textColor; + } + + const float* myColorValues = CGColorGetComponents(shadowColor.CGColor); + + CGContextRef myContext = UIGraphicsGetCurrentContext(); + CGContextSaveGState(myContext); + + CGColorSpaceRef myColorSpace = CGColorSpaceCreateDeviceRGB(); + CGColorRef myColor = CGColorCreate(myColorSpace, myColorValues); + CGContextSetShadowWithColor (myContext, myShadowOffset, shadowBlur, myColor); + + [super drawTextInRect:rect]; + + CGColorRelease(myColor); + CGColorSpaceRelease(myColorSpace); + + CGContextRestoreGState(myContext); +} + +- (void)setShadowBlur:(float)blur +{ + shadowBlur = blur; + [self setNeedsDisplay]; +} + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/Classes/SleepTimerController.h b/Classes/SleepTimerController.h new file mode 100644 index 0000000..275389c --- /dev/null +++ b/Classes/SleepTimerController.h @@ -0,0 +1,30 @@ +// +// SleepTimerController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 3/24/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import +#import "TBFOceanWaveGenerator.h" + + +@interface SleepTimerController : NSObject { + NSTimer *sleepTimer; + TBFOceanWaveGenerator *oceanWaveGenerator; + BOOL sleepTimerIsOn; + id interfaceDelegate; + float volumeBeforeFadout; + float volume; +} + ++ (SleepTimerController *)sharedSleepTimerController; +- (void)startSleepTimer; +- (void)stopSleepTimer:(NSTimer *)theTimer; + +@property (assign) id interfaceDelegate; +@property BOOL sleepTimerIsOn; +@property float volume; + +@end diff --git a/Classes/SleepTimerController.m b/Classes/SleepTimerController.m new file mode 100644 index 0000000..7206835 --- /dev/null +++ b/Classes/SleepTimerController.m @@ -0,0 +1,194 @@ +// +// SleepTimerController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 3/24/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "SleepTimerController.h" +#import "Constants.h" +#import +#import "Sleep_Blaster_touchAppDelegate.h" +#import +#import + +static SleepTimerController *sharedSleepTimerController = nil; + +@implementation SleepTimerController + +@synthesize interfaceDelegate; +@synthesize sleepTimerIsOn; +@synthesize volume; + +BOOL alreadyIsGeneratingNotifications = NO; + + ++ (SleepTimerController *)sharedSleepTimerController { + @synchronized(self) { + if (sharedSleepTimerController == nil) + [[self alloc] init]; + } + + return sharedSleepTimerController; +} + ++ (id)allocWithZone:(NSZone *)zone { + @synchronized(self) { + if (sharedSleepTimerController == nil) { + sharedSleepTimerController = [super allocWithZone:zone]; + return sharedSleepTimerController; + } + } + + return nil; +} + +- (id)copyWithZone:(NSZone *)zone { + return self; +} + +- (id)init { + if ([super init] == nil) + return nil; + + self.sleepTimerIsOn = NO; + + return self; +} + +- (id)retain { + return self; +} + +- (unsigned)retainCount { + return UINT_MAX; +} + +- (void)release { + // Do nothing. +} + +- (id)autorelease { + return self; +} + +- (void)dealloc { + [super dealloc]; +// [oceanWaveGenerator release]; +} + +- (void)playbackStateDidChange:(NSNotification *)notification +{ +// NSLog(@"playback did change!"); + // If the user manually stops the music, let's stop the whole sleep timer so it's not just going without any music. + if (sleepTimerIsOn && + [[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue] == 0 && + [MPMusicPlayerController iPodMusicPlayer].playbackState != MPMusicPlaybackStatePlaying) + { +// NSLog(@"it was playing, but it's not. stopping the sleep timer."); + [[SleepTimerController sharedSleepTimerController] stopSleepTimer:nil]; + } + + // After the sleep timer ends (and has faded out), we have to set the volume back to what it was before it faded out. + // We do this in a different method because if we set the volume right after stopping the music, sometimes it + // sets the volume before the music is actually stopped. + if ([MPMusicPlayerController iPodMusicPlayer].playbackState == MPMusicPlaybackStateStopped) + { + // if volumeBeforeFadout was set before the fadeout, and if the music player's volume hasn't already been + // set on again by something else, then let's set it back to what it was before the fadeout. + if (volumeBeforeFadout && + [MPMusicPlayerController iPodMusicPlayer].volume ) { + [MPMusicPlayerController iPodMusicPlayer].volume = volumeBeforeFadout; + } + } +} + +- (void)startSleepTimer +{ + if (!alreadyIsGeneratingNotifications) + { + alreadyIsGeneratingNotifications = YES; + [[MPMusicPlayerController iPodMusicPlayer] beginGeneratingPlaybackNotifications]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(playbackStateDidChange:) + name:MPMusicPlayerControllerPlaybackStateDidChangeNotification + object:[MPMusicPlayerController iPodMusicPlayer]]; + } + + self.sleepTimerIsOn = YES; + + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue] == 0) + { + MPMusicPlayerController *musicPlayerController = [MPMusicPlayerController iPodMusicPlayer]; + musicPlayerController.volume = self.volume; + + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + [musicPlayerController setQueueWithItemCollection:mainDelegate.sleepTimerSongsCollection]; + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerMusicShuffle] boolValue]) { + musicPlayerController.shuffleMode = MPMusicShuffleModeSongs; + } else { + musicPlayerController.shuffleMode = MPMusicShuffleModeOff; + } + + [musicPlayerController play]; + + } + else if ([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue] == 1) + { + [[TBFOceanWaveGenerator sharedOceanWaveGenerator] play]; + } + + sleepTimer = [NSTimer scheduledTimerWithTimeInterval:[[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerSeconds] intValue] + target:self + selector:@selector(stopSleepTimer:) + userInfo:nil repeats:NO]; +} + +- (void)stopSleepTimer:(NSTimer *)timer +{ + if (sleepTimer) { + [sleepTimer invalidate]; + } + + self.sleepTimerIsOn = NO; + + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue] == 0) + { + MPMusicPlayerController *musicPlayerController = [MPMusicPlayerController iPodMusicPlayer]; + volumeBeforeFadout = musicPlayerController.volume; + if (timer) // gradually ramp the volume down, ONLY IF the timer naturally ran out of time. + { + float rampVolume; + for (rampVolume = musicPlayerController.volume; rampVolume >= 0; rampVolume -= .01) { + [musicPlayerController setVolume:rampVolume]; + // pause 32/100th of a second (320,000 microseconds) between adjustments. + usleep(320000); + } + } + [musicPlayerController stop]; + + } else if ([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue] == 1) { + [[TBFOceanWaveGenerator sharedOceanWaveGenerator] stop]; + } + + if (self.interfaceDelegate) { + [interfaceDelegate hideArtworkContainerView]; + } + + if (![[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue]) { + [[DeepSleepPreventer sharedDeepSleepPreventer] stopPreventSleep]; + } +} + +- (void)setVolume:(float)newVolume +{ + volume = newVolume; + + if (self.sleepTimerIsOn) + { + [MPMusicPlayerController iPodMusicPlayer].volume = volume; + } +} + +@end diff --git a/Classes/Sleep_Blaster_touchAppDelegate.h b/Classes/Sleep_Blaster_touchAppDelegate.h new file mode 100644 index 0000000..d83a670 --- /dev/null +++ b/Classes/Sleep_Blaster_touchAppDelegate.h @@ -0,0 +1,59 @@ +// +// Sleep_Blaster_touchAppDelegate.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 6/9/09. +// Copyright The Byte Factory 2009. All rights reserved. +// + +#import +#import +#import "DeepSleepPreventer.h" +#import "ClockViewController.h" +#import "AlarmRingingViewController.h" +#import "MapViewController.h" +#import "AlarmSettingsViewController.h" +#import "SleepTimerSettingsViewController.h" + +@interface Sleep_Blaster_touchAppDelegate : NSObject { + UIWindow *window; + UITabBarController *tabBarController; + IBOutlet ClockViewController *clockViewController; + AlarmRingingViewController *alarmRingingViewController; + MapViewController *mapViewController; + UINavigationController *alarmSettingsNavigationController; + UINavigationController *sleepTimerSettingsNavigationController; + + UIView *previousView; + + MPMediaItemCollection *alarmSongsCollection; + MPMediaItemCollection *sleepTimerSongsCollection; + BOOL hasLoadedAlarmSongsCollection; + BOOL hasLoadedSleepTimerSongsCollection; + BOOL backgroundSupported; + + BOOL bypassAlarm; +} + +- (void)showAlarmRingingView; +- (void)hideAlarmRingingView; +- (void)flipToSettings; +- (IBAction)flipToClockView:(id)sender; +- (void)scheduleAlarmNotificationsIfNeeded; + +- (void)loadSongsAsynchronously:(id)sender; + +@property (nonatomic, retain) ClockViewController *clockViewController; +@property (nonatomic, retain) IBOutlet UIWindow *window; +@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController; +@property (nonatomic, retain) MapViewController *mapViewController; +@property (nonatomic, retain) MPMediaItemCollection *alarmSongsCollection; +@property (nonatomic, retain) MPMediaItemCollection *sleepTimerSongsCollection; +@property (nonatomic) BOOL hasLoadedAlarmSongsCollection; +@property (nonatomic) BOOL hasLoadedSleepTimerSongsCollection; +@property (nonatomic) BOOL backgroundSupported; +@property (nonatomic, retain) UIView *previousView; +@property (nonatomic, retain) UINavigationController *alarmSettingsNavigationController; +@property (nonatomic, retain) UINavigationController *sleepTimerSettingsNavigationController; +@property (nonatomic) BOOL bypassAlarm; +@end diff --git a/Classes/Sleep_Blaster_touchAppDelegate.m b/Classes/Sleep_Blaster_touchAppDelegate.m new file mode 100644 index 0000000..67cac01 --- /dev/null +++ b/Classes/Sleep_Blaster_touchAppDelegate.m @@ -0,0 +1,414 @@ +// +// Sleep_Blaster_touchAppDelegate.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 6/9/09. +// Copyright The Byte Factory 2009. All rights reserved. +// + +#import "Sleep_Blaster_touchAppDelegate.h" +#import "AlarmRingingViewController.h" +#import "Constants.h" +#import "ClockViewController.h" +#include +#import "SleepTimerController.h" +#import "AlarmController.h" + +@implementation Sleep_Blaster_touchAppDelegate + +@synthesize window; +@synthesize clockViewController; +@synthesize tabBarController; +@synthesize mapViewController; +@synthesize alarmSongsCollection; +@synthesize sleepTimerSongsCollection; +@synthesize hasLoadedAlarmSongsCollection; +@synthesize hasLoadedSleepTimerSongsCollection; +@synthesize backgroundSupported; +@synthesize previousView; +@synthesize alarmSettingsNavigationController; +@synthesize sleepTimerSettingsNavigationController; +@synthesize bypassAlarm; + +int numberOfNotifications = 0; + ++ (void)initialize +{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys: + [NSDate date], kAlarmDate, + [NSNumber numberWithBool:NO], kEnableVoiceControls, + [NSNumber numberWithBool:NO], kAlarmOn, + [NSNumber numberWithBool:NO], kAlarmMusicShuffle, + [NSNumber numberWithBool:NO], kSleepTimerMusicShuffle, + [NSNumber numberWithBool:NO], kEnableDynamiteMode, + [NSNumber numberWithInt:2], kAlarmPlayInterval, + [NSNumber numberWithInt:2], kAlarmPauseInterval, + [NSNumber numberWithInt:1], kVoiceFunction, + [NSNumber numberWithInt:1], kSleepTimerFunction, + [NSNumber numberWithInt:3600], kSleepTimerSeconds, + [NSNumber numberWithInt:0], kAlarmMode, + [NSNumber numberWithBool:NO], kHasShownDrawingMessage, + [NSNumber numberWithBool:NO], kHasShownChargingMessage, + [NSNumber numberWithBool:NO], kHasShownBrightnessMessage, + [NSNumber numberWithBool:NO], kHasShownBackgroundMessage, + [NSNumber numberWithInt:10], kSnoozeMinutes, + [[NSTimeZone defaultTimeZone] name], kOldTimeZone, NULL]; + + [defaults registerDefaults:appDefaults]; + +} +- (id)init +{ + if (self = [super init] ) { + + hasLoadedAlarmSongsCollection = NO; + hasLoadedSleepTimerSongsCollection = NO; + + UIDevice* device = [UIDevice currentDevice]; + backgroundSupported = NO; + if ([device respondsToSelector:@selector(isMultitaskingSupported)]) { + backgroundSupported = device.multitaskingSupported; + } + + } + return self; +} +/* +- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification +{ + if ([[notification.userInfo objectForKey:@"PresentedImmediately"] boolValue] == YES) + { + NSLog(@"presented immediately!"); + + } else { + NSLog(@"not presented immediately"); + self.bypassAlarm = YES; + + } + NSLog(@"did receive local notification"); +} +*/ +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + if (self.backgroundSupported) + { + if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]) + { + NSLog(@"local notification!"); + // One of the notifications has gone off... + self.bypassAlarm = YES; + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:NO] forKey:kAlarmOn]; + } +// [[UIApplication sharedApplication] cancelAllLocalNotifications]; +// NSLog(@"scheduled notifications now: %d", [[UIApplication sharedApplication] scheduledLocalNotifications].count); +// NSLog(@"notifications before: %d", numberOfNotifications); + + } + + [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque; + [UIApplication sharedApplication].statusBarHidden = YES; + + // We have to create the map view controller at the very beginning, because this is what controls the location updates and stuff. + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + mapViewController = [[MapViewController alloc] initWithNibName:@"MapView-iPad" bundle:nil]; + } else { + mapViewController = [[MapViewController alloc] initWithNibName:@"MapView" bundle:nil]; + } + // // Force it to load the mapViewController immediately. + // mapViewController.view; + + [window addSubview:clockViewController.view]; + + [NSThread detachNewThreadSelector:@selector(loadSongsAsynchronously:) toTarget:self withObject:nil]; + + + return NO; +} + +- (void)flipToSettings +{ + [UIApplication sharedApplication].statusBarHidden = NO; + +// self.tabBarController = [[UITabBarController alloc] init]; +// +// NSArray* controllers = [NSArray arrayWithObjects:self.alarmSettingsNavigationController, self.sleepTimerSettingsNavigationController, nil]; +// tabBarController.viewControllers = controllers; + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:1.0]; + [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:YES]; + + [window addSubview:self.tabBarController.view]; // retains tabBarController + [clockViewController.view removeFromSuperview]; + + [UIView commitAnimations]; +} + +- (IBAction)flipToClockView:(id)sender +{ + [UIApplication sharedApplication].statusBarHidden = YES; + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:1.0]; + [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES]; + + [window addSubview:clockViewController.view]; + [self.tabBarController.view removeFromSuperview]; // releases tabBarController + + [UIView commitAnimations]; +} + +- (void)showAlarmRingingView +{ + [UIApplication sharedApplication].statusBarHidden = YES; + + alarmRingingViewController = [[[AlarmRingingViewController alloc] initWithNibName:@"AlarmRingingView" bundle:nil] autorelease]; + + self.previousView = [window.subviews objectAtIndex:0]; + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:1.0]; + [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES]; + + [self.previousView removeFromSuperview]; + [window addSubview:alarmRingingViewController.view]; + + [UIView commitAnimations]; +} + +- (void)hideAlarmRingingView +{ + if (self.previousView == tabBarController.view) { + [UIApplication sharedApplication].statusBarHidden = NO; + } + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:1.0]; + [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:NO]; + + [alarmRingingViewController.view removeFromSuperview]; + [window addSubview:self.previousView]; + + [UIView commitAnimations]; +} + +- (void)loadSongsAsynchronously:(id)sender +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + if ([[NSUserDefaults standardUserDefaults] objectForKey:kAlarmSongsCollection]) { + self.alarmSongsCollection = [NSKeyedUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmSongsCollection]]; + } +/* if (self.alarmSongsCollection.count == 0) // if there are no songs selected.... + { + MPMediaQuery *everything = [[MPMediaQuery alloc] init]; + if (everything.items.count) // if there are songs in the user's iPod library, add them all. + { + self.alarmSongsCollection = [MPMediaItemCollection collectionWithItems:everything.items]; + //[self.alarmSongsCollection retain]; + } + [everything release]; + } +*/ + hasLoadedAlarmSongsCollection = YES; + [[self.alarmSettingsNavigationController.viewControllers objectAtIndex:0] setLabelInMusicCell]; + + if ([[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerSongsCollection]) { + self.sleepTimerSongsCollection = [NSKeyedUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerSongsCollection]]; + } + hasLoadedSleepTimerSongsCollection = YES; + [[self.sleepTimerSettingsNavigationController.viewControllers objectAtIndex:0] setLabelInMusicCell]; + + [pool release]; +} + + - (void)applicationWillTerminate:(UIApplication *)application +{ + [self scheduleAlarmNotificationsIfNeeded]; + +/*// NSData *alarmSongsData = [NSKeyedArchiver archivedDataWithRootObject:self.alarmSongsCollection]; + NSData *sleepTimerSongsData = [NSKeyedArchiver archivedDataWithRootObject:self.sleepTimerSongsCollection]; + +// [[NSUserDefaults standardUserDefaults] setObject:alarmSongsData forKey:kAlarmSongsCollection]; + [[NSUserDefaults standardUserDefaults] setObject:sleepTimerSongsData forKey:kSleepTimerSongsCollection]; + NSLog(@"about to save the data!"); + NSLog(@"terminating"); + */ +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ +// [[UIApplication sharedApplication] cancelAllLocalNotifications]; +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + NSLog(@"enter background"); + [self scheduleAlarmNotificationsIfNeeded]; + if (![SleepTimerController sharedSleepTimerController].sleepTimerIsOn) + { + [[DeepSleepPreventer sharedDeepSleepPreventer] stopPreventSleep]; + } +} + +- (void)scheduleAlarmNotificationsIfNeeded +{ + if (self.backgroundSupported) + { + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue] && ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] boolValue] == 0)) + { + UILocalNotification *notification = [[UILocalNotification alloc] init]; + notification.fireDate = [[AlarmController sharedAlarmController] dateAlarmWillGoOff]; + notification.soundName = @"beep.wav"; + notification.alertAction = @"Turn off"; + notification.alertBody = @"Hey, it's time to wake up!"; + [[UIApplication sharedApplication] scheduleLocalNotification:notification]; + + } + numberOfNotifications = [[UIApplication sharedApplication] scheduledLocalNotifications].count; +// NSLog(@"number of notifications now... %d", numberOfNotifications); + } +} + +-(void) applicationWillResignActive:(UIApplication *)application { +// NSLog(@"resign active"); + if (self.backgroundSupported) + { + numberOfNotifications = [[UIApplication sharedApplication] scheduledLocalNotifications].count; + } + // If the user puts the iPhone to sleep while the alarm is set for "time" mode, just don't let it go into deep sleep. + if (([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue] && ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] boolValue] == 0)) + || [SleepTimerController sharedSleepTimerController].sleepTimerIsOn) + { + [[DeepSleepPreventer sharedDeepSleepPreventer] startPreventSleep]; +// [TBFOceanWaveGenerator sharedOceanWaveGenerator].silentMode = YES; +// [[TBFOceanWaveGenerator sharedOceanWaveGenerator] play]; + } + if (![[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue]) { + [mapViewController stopTrackingLocation]; + } + } + +/* +- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification +{ + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:NO] forKey:kAlarmOn]; + } +} +*/ + +- (UINavigationController *)alarmSettingsNavigationController +{ + if (!alarmSettingsNavigationController) + { + AlarmSettingsViewController *viewController; + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + // The device is an iPad running iPhone 3.2 or later. + viewController = [[AlarmSettingsViewController alloc] initWithNibName:@"AlarmSettingsView-iPad" bundle:nil]; + } else { + // The device is an iPhone or iPod touch. + viewController = [[AlarmSettingsViewController alloc] initWithNibName:@"AlarmSettingsView" bundle:nil]; + UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStylePlain target:self action:@selector(flipToClockView:)]; + viewController.navigationItem.rightBarButtonItem = doneButton; + } + + alarmSettingsNavigationController = [[UINavigationController alloc] initWithRootViewController:viewController]; + alarmSettingsNavigationController.delegate = viewController; + if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) + { + alarmSettingsNavigationController.navigationBar.barStyle = UIBarStyleBlack; + alarmSettingsNavigationController.navigationBar.translucent = YES; + } + + [viewController release]; + } + + return alarmSettingsNavigationController; +} + +- (UINavigationController *)sleepTimerSettingsNavigationController +{ + if (!sleepTimerSettingsNavigationController) + { + SleepTimerSettingsViewController *viewController; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + // The device is an iPad running iPhone 3.2 or later. + viewController = [[SleepTimerSettingsViewController alloc] initWithNibName:@"SleepTimerSettingsView-iPad" bundle:nil]; + } else { + // The device is an iPhone or iPod touch. + viewController = [[SleepTimerSettingsViewController alloc] initWithNibName:@"SleepTimerSettingsView" bundle:nil]; + UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStylePlain target:self action:@selector(flipToClockView:)]; + viewController.navigationItem.rightBarButtonItem = doneButton; + } + + sleepTimerSettingsNavigationController = [[UINavigationController alloc] initWithRootViewController:viewController]; + + if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) + { + sleepTimerSettingsNavigationController.navigationBar.barStyle = UIBarStyleBlack; + sleepTimerSettingsNavigationController.navigationBar.translucent = YES; + } + + [viewController release]; + } + + return sleepTimerSettingsNavigationController; +} + +-(void) applicationDidBecomeActive:(UIApplication *)application +{ + if (self.backgroundSupported) + { + if ([[UIApplication sharedApplication] scheduledLocalNotifications].count < numberOfNotifications) + { + // One of the notifications has gone off... + self.bypassAlarm = YES; + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:NO] forKey:kAlarmOn]; + } + [[UIApplication sharedApplication] cancelAllLocalNotifications]; +// NSLog(@"scheduled notifications now: %d", [[UIApplication sharedApplication] scheduledLocalNotifications].count); +// NSLog(@"notifications before: %d", numberOfNotifications); + + } + + [[DeepSleepPreventer sharedDeepSleepPreventer] stopPreventSleep]; + + if (!self.tabBarController) + { + self.tabBarController = [[UITabBarController alloc] init]; + NSArray* controllers = [NSArray arrayWithObjects:self.alarmSettingsNavigationController, self.sleepTimerSettingsNavigationController, nil]; + self.tabBarController.viewControllers = controllers; + } +} + +/* +// Optional UITabBarControllerDelegate method +- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { +} +*/ + +/* +// Optional UITabBarControllerDelegate method +- (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed { +} +*/ + +- (void)dealloc { + [tabBarController release]; + [alarmSettingsNavigationController release]; + [sleepTimerSettingsNavigationController release]; + [clockViewController release]; + [mapViewController release]; + [window release]; + [super dealloc]; +} + +@end + diff --git a/Classes/TBFOceanWaveGenerator.h b/Classes/TBFOceanWaveGenerator.h new file mode 100644 index 0000000..2122674 --- /dev/null +++ b/Classes/TBFOceanWaveGenerator.h @@ -0,0 +1,28 @@ +// +// TBFOceanWaveGenerator.h +// Sleep Blaster +// +// Created by Eamon Ford on 9/25/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import +#import + +@interface TBFOceanWaveGenerator : NSObject { + AVAudioPlayer *pinkNoise; + NSTimer *timer; + BOOL shouldStop; + BOOL silentMode; + float newVolume; +} + ++ (TBFOceanWaveGenerator *)sharedOceanWaveGenerator; + +- (void)play; +- (void)stop; +- (void)goThroughOneWaveCycle; + +@property (nonatomic) BOOL silentMode; + +@end diff --git a/Classes/TBFOceanWaveGenerator.m b/Classes/TBFOceanWaveGenerator.m new file mode 100644 index 0000000..6b57bb1 --- /dev/null +++ b/Classes/TBFOceanWaveGenerator.m @@ -0,0 +1,130 @@ +// +// TBFOceanWaveGenerator.m +// Sleep Blaster +// +// Created by Eamon Ford on 9/25/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import "TBFOceanWaveGenerator.h" +#import "Randomizer.h" + +static TBFOceanWaveGenerator *sharedOceanWaveGenerator = nil; + +@implementation TBFOceanWaveGenerator + +@synthesize silentMode; + ++ (TBFOceanWaveGenerator *)sharedOceanWaveGenerator { + @synchronized(self) { + if (sharedOceanWaveGenerator == nil) + [[self alloc] init]; + } + + return sharedOceanWaveGenerator; +} + +- (id)init { + if (self = [super init]) { + shouldStop = NO; + silentMode = NO; + pinkNoise = [[AVAudioPlayer alloc] initWithData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pinkNoise" ofType:@"m4a"]] error:NULL]; + [pinkNoise retain]; + pinkNoise.numberOfLoops = -1; + } + return self; +} + +- (void)play +{ + shouldStop = NO; + + // Fade in the volume. + pinkNoise.volume = 0.0; + + [pinkNoise play]; + + [self goThroughOneWaveCycle]; +} + +- (void)goThroughOneWaveCycle +{ + Randomizer *randomizer = [[Randomizer alloc] init]; + newVolume = (float)([randomizer randomWithMax:90]+10) / 100; + + if (shouldStop) { + newVolume = 0.0; + } + + timer = [NSTimer scheduledTimerWithTimeInterval:0.05 + target:self + selector:@selector(adjustVolumeOneIncrement:) + userInfo:nil + repeats:YES]; +} + +- (void)stop +{ + // Fade out the volume. + shouldStop = YES; + + [self goThroughOneWaveCycle]; +} + +- (void)adjustVolumeOneIncrement:(NSTimer*)theTimer +{ + float volumeIncrement; + if (newVolume < pinkNoise.volume) { + volumeIncrement = -0.007; + } else { + volumeIncrement = 0.007; + } + + float tempVolume = pinkNoise.volume+volumeIncrement; + if (tempVolume > newVolume+0.007 || tempVolume < newVolume-0.007) { // give a little bit of leeway here + pinkNoise.volume = tempVolume; + } else { // we've reached the target volume + [theTimer invalidate]; // stop adjusting the volume one increment + if (shouldStop) { + [pinkNoise stop]; // stop everything + } else { + [self goThroughOneWaveCycle]; // generate more waves + } + } +} + +#pragma mark - +#pragma mark Singleton Pattern + ++ (id)allocWithZone:(NSZone *)zone { + @synchronized(self) { + if (sharedOceanWaveGenerator == nil) { + sharedOceanWaveGenerator = [super allocWithZone:zone]; + return sharedOceanWaveGenerator; + } + } + + return nil; +} + +- (id)copyWithZone:(NSZone *)zone { + return self; +} + +- (id)retain { + return self; +} + +- (unsigned)retainCount { + return UINT_MAX; +} + +- (void)release { + // Do nothing. +} + +- (id)autorelease { + return self; +} + +@end diff --git a/Classes/untitled.h b/Classes/untitled.h new file mode 100644 index 0000000..ea6b233 --- /dev/null +++ b/Classes/untitled.h @@ -0,0 +1,16 @@ +// +// untitled.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 11/29/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import + + +@interface untitled : UIView { + +} + +@end diff --git a/Classes/untitled.m b/Classes/untitled.m new file mode 100644 index 0000000..e4b9e9e --- /dev/null +++ b/Classes/untitled.m @@ -0,0 +1,33 @@ +// +// untitled.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 11/29/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import "untitled.h" + + +@implementation untitled + + +- (id)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { + // Initialization code + } + return self; +} + + +- (void)drawRect:(CGRect)rect { + // Drawing code +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/ClockView.h b/ClockView.h new file mode 100644 index 0000000..da7d677 --- /dev/null +++ b/ClockView.h @@ -0,0 +1,16 @@ +// +// ClockBackgroundView.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 12/28/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import + + +@interface ClockView : UIView { + BOOL subviewsAreInPortraitMode; +} + +@end diff --git a/ClockView.m b/ClockView.m new file mode 100644 index 0000000..9133c31 --- /dev/null +++ b/ClockView.m @@ -0,0 +1,102 @@ +// +// ClockBackgroundView.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 12/28/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import "ClockView.h" +#import "ShadowedLabel.h" + +@implementation ClockView + + +- (id)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { + subviewsAreInPortraitMode = NO; + [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; + } + return self; +} + +- (void)layoutSubviews +{ + if ((UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation) && subviewsAreInPortraitMode) || + (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) && subviewsAreInPortraitMode == NO) || + !UIDeviceOrientationIsValidInterfaceOrientation([UIDevice currentDevice].orientation)) + { + return; + } + + float ratio = [UIScreen mainScreen].bounds.size.height/[UIScreen mainScreen].bounds.size.width; + + // This is simply the number of pixels from the top of the screen to the top of the clock image when it's in portrait, + // and centered on the screen. + float yOffset = [UIScreen mainScreen].bounds.size.height/2 - [UIScreen mainScreen].bounds.size.width/ratio/2; + + if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation)) + { + ratio = 1.0/ratio; + } + + for (int i = 0; i < self.subviews.count; i++) + { + UIView *view = [self.subviews objectAtIndex:i]; + CGRect frame = view.frame; + +/* if (view == rightSettingsButton) + { + if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation)) + { + frame.origin.x = [UIScreen mainScreen].bounds.size.width - frame.size.width - 10.0; + frame.origin.y = [UIScreen mainScreen].bounds.size.height - frame.size.height - 10.0; + NSLog(@"positioning the button at: %f, %f", frame.origin.x, frame.origin.y); + } else { + frame.origin.x = [UIScreen mainScreen].bounds.size.height - frame.size.width - 10.0; + frame.origin.y = [UIScreen mainScreen].bounds.size.width - frame.size.height - 10.0; + NSLog(@"positioning the button at: %f, %f", frame.origin.x, frame.origin.y); + } + + + } else*/ + + if ([view class] != [UIButton class]) { + + if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) + { + frame.origin.y -= yOffset; + } + + frame.size.width *= ratio; + frame.size.height *= ratio; + frame.origin.x *= ratio; + frame.origin.y *= ratio; + + if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation)) + { + frame.origin.y += yOffset; + } + + if ([view class] == [ShadowedLabel class]) + { + UIFont *originalFont = ((UILabel*)view).font; + UIFont *newFont = [UIFont fontWithName:originalFont.fontName size:originalFont.pointSize*ratio]; + + ((UILabel*)view).font = newFont; + } + } + view.frame = frame; + } + + subviewsAreInPortraitMode = !subviewsAreInPortraitMode; +} + + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/ClockView.png b/ClockView.png new file mode 100644 index 0000000..92691e9 Binary files /dev/null and b/ClockView.png differ diff --git a/ClockViewController.h b/ClockViewController.h new file mode 100644 index 0000000..a276936 --- /dev/null +++ b/ClockViewController.h @@ -0,0 +1,79 @@ +// +// ClockViewController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 11/24/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import +#import "ShadowedLabel.h" + +@interface ClockViewController : UIViewController { + + IBOutlet UIView *portraitClockBackgroundView; + IBOutlet ShadowedLabel *portraitHourLabel1; + IBOutlet ShadowedLabel *portraitHourLabel2; + IBOutlet ShadowedLabel *portraitMinuteLabel1; + IBOutlet ShadowedLabel *portraitMinuteLabel2; + IBOutlet ShadowedLabel *portraitSecondLabel1; + IBOutlet ShadowedLabel *portraitSecondLabel2; + IBOutlet ShadowedLabel *portraitSunLabel; + IBOutlet ShadowedLabel *portraitMonLabel; + IBOutlet ShadowedLabel *portraitTueLabel; + IBOutlet ShadowedLabel *portraitWedLabel; + IBOutlet ShadowedLabel *portraitThuLabel; + IBOutlet ShadowedLabel *portraitFriLabel; + IBOutlet ShadowedLabel *portraitSatLabel; + IBOutlet ShadowedLabel *portraitAmLabel; + IBOutlet ShadowedLabel *portraitPmLabel; + IBOutlet ShadowedLabel *portraitColonLabel; + IBOutlet UIImageView *portraitAlarmBell; + + IBOutlet UIView *landscapeClockBackgroundView; + IBOutlet ShadowedLabel *hourLabel1; + IBOutlet ShadowedLabel *hourLabel2; + IBOutlet ShadowedLabel *minuteLabel1; + IBOutlet ShadowedLabel *minuteLabel2; + IBOutlet ShadowedLabel *secondLabel1; + IBOutlet ShadowedLabel *secondLabel2; + IBOutlet ShadowedLabel *sunLabel; + IBOutlet ShadowedLabel *monLabel; + IBOutlet ShadowedLabel *tueLabel; + IBOutlet ShadowedLabel *wedLabel; + IBOutlet ShadowedLabel *thuLabel; + IBOutlet ShadowedLabel *friLabel; + IBOutlet ShadowedLabel *satLabel; + IBOutlet ShadowedLabel *amLabel; + IBOutlet ShadowedLabel *pmLabel; + IBOutlet ShadowedLabel *colonLabel; + IBOutlet UIImageView *alarmBell; + IBOutlet UIButton *rightSettingsButton; + + IBOutlet UIImageView *backgroundImageView; + + IBOutlet UIWindow *window; + + UIPopoverController *alarmPopoverController; + UIPopoverController *sleepTimerPopoverController; + + NSTimer *timer; +} + +//- (void)layoutForPortraitMode; +//- (void)layoutForLandscapeMode; + + +- (void)setFontsForLabels; +- (void)positionSettingsButtons; +- (void)setCurrentDateAndTimeLabels; +- (IBAction)infoButtonTapped:(id)sender; +- (IBAction)sleepTimerButtonTapped:(id)sender; + +@property (nonatomic, retain) NSTimer *timer; +@property (nonatomic, retain) UIPopoverController *alarmPopoverController; +@property (nonatomic, retain) UIPopoverController *sleepTimerPopoverController; +@property (nonatomic, retain) UIButton *rightSettingsButton; + + +@end diff --git a/ClockViewController.m b/ClockViewController.m new file mode 100644 index 0000000..9ec16a2 --- /dev/null +++ b/ClockViewController.m @@ -0,0 +1,564 @@ +// +// ClockViewController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 11/24/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import "ClockViewController.h" +#import +#import +#import "Constants.h" +#import +#import +#import "SCListener.h" +#import "AlarmRingingViewController.h" +#import "AlarmController.h" +#import "Sleep_Blaster_touchAppDelegate.h" +#import "NSLocale+Misc.h" +#import "AlarmSettingsViewController.h" + +#define degreesToRadian(x) (M_PI * x / 180.0) + +@implementation ClockViewController + +@synthesize timer; +@synthesize alarmPopoverController; +@synthesize sleepTimerPopoverController; +@synthesize rightSettingsButton; + +BOOL alreadyFadedInClock = NO; +BOOL alarmPopoverWasVisibleBeforeRotation = NO; +BOOL sleepTimerPopoverWasVisibleBeforeRotation = NO; +UIInterfaceOrientation oldOrientation; + +NSUInteger loadFonts() +{ + NSUInteger newFontCount = 0; + NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"com.apple.GraphicsServices"]; + const char *frameworkPath = [[frameworkBundle executablePath] UTF8String]; + if (frameworkPath) { + void *graphicsServices = dlopen(frameworkPath, RTLD_NOLOAD | RTLD_LAZY); + if (graphicsServices) { + BOOL (*GSFontAddFromFile)(const char *) = dlsym(graphicsServices, "GSFontAddFromFile"); + if (GSFontAddFromFile) + for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:nil]) + newFontCount += GSFontAddFromFile([fontFile UTF8String]); + } + } + return newFontCount; +} + +/* + // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + // Custom initialization + } + return self; +} +*/ + + +- (void)viewDidLoad { + [super viewDidLoad]; + NSLog(@"clock view did load"); + + + CGRect rect = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height); + self.view.frame = rect; + + loadFonts(); + + [self setFontsForLabels]; + [self setCurrentDateAndTimeLabels]; + [self positionSettingsButtons]; + +// CGRect rect = rightSettingsButton.frame; +// rect.origin.x = [UIScreen mainScreen].bounds.size.width - rect.size.width - 10.0; +// rect.origin.y = [UIScreen mainScreen].bounds.size.height - rect.size.height - 10.0; +// rightSettingsButton.frame = rect; + + self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self + selector:@selector(updateClock:) + userInfo:nil repeats:YES]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(userDefaultsChanged:) + name:NSUserDefaultsDidChangeNotification + object:[NSUserDefaults standardUserDefaults]]; + + + [[AlarmController sharedAlarmController] setupAlarm:self]; +} + +- (void)userDefaultsChanged:(NSNotification *)notification +{ + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.3]; + + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue]) + { + alarmBell.alpha = 1.0; + } else { + + portraitAlarmBell.alpha = 0.0; + alarmBell.alpha = 0.0; + + } + + [UIView commitAnimations]; +} + +/*- (void)didEnterBackground:(NSNotification *)notification +{ + if (self.timer) + { + [self.timer invalidate]; + } + + NSLog(@"did enter background!"); +} + +- (void)didBecomeActive:(NSNotification *)notification +{ + NSLog(@"did become active!"); + + if (![timer isValid]) + { + NSLog(@"revalidating the timer!"); + timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self + selector:@selector(updateClock:) + userInfo:nil repeats:YES]; + } else { + NSLog(@"it is valid already..."); + } +} +*/ +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue]) + { + portraitAlarmBell.alpha = 1.0; + alarmBell.alpha = 1.0; + } else { + portraitAlarmBell.alpha = 0.0; + alarmBell.alpha = 0.0; + } + + /*if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)) + { + NSLog(@"it's portrait!"); + } else if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) + { + NSLog(@"it's landscape!"); + } else if (!UIDeviceOrientationIsValidInterfaceOrientation([UIDevice currentDevice].orientation)) + { + NSLog(@"it's not a valid orientation!"); + }*/ +} + +- (void)viewDidAppear:(BOOL)animated +{ + if (!alreadyFadedInClock) + { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:1.0]; + self.view.alpha = 1.0; + [UIView commitAnimations]; + + alreadyFadedInClock = YES; + } + + NSString *deviceType = [UIDevice currentDevice].model; + if([deviceType isEqualToString:@"iPhone"]) + { + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue]) + { + if (![[[NSUserDefaults standardUserDefaults] objectForKey:kHasShownBrightnessMessage] boolValue]) + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Dimming the screen at night" message:@"You can dim the screen by double-tapping on it." + delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; + [alert show]; + [alert release]; + + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kHasShownBrightnessMessage]; + } + } + } + +} + +- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration +{ + oldOrientation = self.interfaceOrientation; + + if (alarmPopoverController.popoverVisible) + { + if (alarmPopoverController.contentViewController.modalViewController) + { +// Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + [((MPMediaPickerController *)alarmPopoverController.contentViewController.modalViewController).delegate mediaPickerDidCancel:alarmPopoverController.contentViewController.modalViewController]; + } + + [alarmPopoverController dismissPopoverAnimated:YES]; + + alarmPopoverWasVisibleBeforeRotation = YES; + } + + [self.view setNeedsLayout]; + +} + +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation +{ + if (alarmPopoverWasVisibleBeforeRotation) + { + [alarmPopoverController presentPopoverFromRect:rightSettingsButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; + alarmPopoverWasVisibleBeforeRotation = NO; + } +} + +- (void)positionSettingsButtons +{ + CGRect rightRect = rightSettingsButton.frame; + if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation) || + !UIDeviceOrientationIsValidInterfaceOrientation([UIDevice currentDevice].orientation)) + { + rightRect.origin.x = [UIScreen mainScreen].bounds.size.width - rightRect.size.width - 10.0; + rightRect.origin.y = [UIScreen mainScreen].bounds.size.height - rightRect.size.height - 10.0; + } else { + rightRect.origin.y = [UIScreen mainScreen].bounds.size.width - rightRect.size.width - 10.0; + rightRect.origin.x = [UIScreen mainScreen].bounds.size.height - rightRect.size.height - 10.0; + + } + rightSettingsButton.frame = rightRect; +} + +- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration +{ + [self positionSettingsButtons]; +} + +- (void)setFontsForLabels +{ + + UIFont *bigFont; + UIFont *mediumFont; + UIFont *smallFont; + UIFont *smallerFont; + + UIColor *shadowColor = [UIColor colorWithRed:0.4 green:0.83 blue:0.9 alpha:0.7]; + hourLabel1.shadowColor = shadowColor; + hourLabel2.shadowColor = shadowColor; + minuteLabel1.shadowColor = shadowColor; + minuteLabel2.shadowColor = shadowColor; + colonLabel.shadowColor = shadowColor; + secondLabel1.shadowColor = shadowColor; + secondLabel2.shadowColor = shadowColor; + + [shadowColor release]; + shadowColor = [UIColor colorWithRed:0.29 green:0.75 blue:0.14 alpha:0.5]; + + sunLabel.shadowColor = shadowColor; + monLabel.shadowColor = shadowColor; + tueLabel.shadowColor = shadowColor; + wedLabel.shadowColor = shadowColor; + thuLabel.shadowColor = shadowColor; + friLabel.shadowColor = shadowColor; + satLabel.shadowColor = shadowColor; + amLabel.shadowColor = shadowColor; + pmLabel.shadowColor = shadowColor; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + // The device is an iPad running iPhone 3.2 or later. + bigFont = [UIFont fontWithName:@"Digital-7" size:216.0]; + mediumFont = [UIFont fontWithName:@"Digital-7" size:108.0]; + smallFont = [UIFont fontWithName:@"Digital-7" size:42.0]; + smallerFont = [UIFont fontWithName:@"Digital-7" size:30.0]; + + + hourLabel1.shadowBlur = 10.0; + hourLabel2.shadowBlur = 10.0; + minuteLabel1.shadowBlur = 10.0; + minuteLabel2.shadowBlur = 10.0; + colonLabel.shadowBlur = 10.0; + secondLabel1.shadowBlur = 10.0; + secondLabel2.shadowBlur = 10.0; + + } else { + // The device is an iPhone or iPod touch. + bigFont = [UIFont fontWithName:@"Digital-7" size:93.0]; + mediumFont = [UIFont fontWithName:@"Digital-7" size:47.0]; + smallFont = [UIFont fontWithName:@"Digital-7" size:18.3]; + smallerFont = [UIFont fontWithName:@"Digital-7" size:13.0]; + } + +/* portraitHourLabel1.font = bigFont; + portraitHourLabel2.font = bigFont; + portraitMinuteLabel1.font = bigFont; + portraitMinuteLabel2.font = bigFont; + portraitColonLabel.font = mediumFont; + portraitSecondLabel1.font = mediumFont; + portraitSecondLabel2.font = mediumFont; + portraitSunLabel.font = smallerFont; + portraitMonLabel.font = smallerFont; + portraitTueLabel.font = smallerFont; + portraitWedLabel.font = smallerFont; + portraitThuLabel.font = smallerFont; + portraitFriLabel.font = smallerFont; + portraitSatLabel.font = smallerFont; + portraitAmLabel.font = smallFont; + portraitPmLabel.font = smallFont; +*/ + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200 + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + // The device is an iPad running iPhone 3.2 or later. + bigFont = [UIFont fontWithName:@"Digital-7" size:288.0]; + mediumFont = [UIFont fontWithName:@"Digital-7" size:144.0]; + smallFont = [UIFont fontWithName:@"Digital-7" size:56]; + smallerFont = [UIFont fontWithName:@"Digital-7" size:40.0]; + } + else +#endif + { + // The device is an iPhone or iPod touch. + bigFont = [UIFont fontWithName:@"Digital-7" size:144.0]; + mediumFont = [UIFont fontWithName:@"Digital-7" size:72.0]; + smallFont = [UIFont fontWithName:@"Digital-7" size:28.0]; + smallerFont = [UIFont fontWithName:@"Digital-7" size:20.0]; + } + + + hourLabel1.font = bigFont; + hourLabel2.font = bigFont; + minuteLabel1.font = bigFont; + minuteLabel2.font = bigFont; + colonLabel.font = mediumFont; + secondLabel1.font = mediumFont; + secondLabel2.font = mediumFont; + sunLabel.font = smallerFont; + monLabel.font = smallerFont; + tueLabel.font = smallerFont; + wedLabel.font = smallerFont; + thuLabel.font = smallerFont; + friLabel.font = smallerFont; + satLabel.font = smallerFont; + amLabel.font = smallFont; + pmLabel.font = smallFont; + +} + +- (void)updateClock:(NSTimer *)theTimer +{ +// NSLog(@"update clock!"); + [self setCurrentDateAndTimeLabels]; +} + +- (void)setCurrentDateAndTimeLabels +{ + NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; + + if ([[[NSCalendar currentCalendar] locale] timeIs24HourFormat]) + { + [dateFormatter setDateFormat:@"HH:mm:ss"]; + } else { + [dateFormatter setDateFormat:@"h:mm:ss"]; + } + + NSString *currentTime = [dateFormatter stringFromDate:[NSDate date]]; + + // We'll go through this string backwards, and then check if the hour should be 1 or 2 digits. + [portraitSecondLabel2 setText:[NSString stringWithFormat:@"%C", [currentTime characterAtIndex:[currentTime length]-1]]]; + [portraitSecondLabel1 setText:[NSString stringWithFormat:@"%C", [currentTime characterAtIndex:[currentTime length]-2]]]; + [portraitMinuteLabel2 setText:[NSString stringWithFormat:@"%C", [currentTime characterAtIndex:[currentTime length]-4]]]; + [portraitMinuteLabel1 setText:[NSString stringWithFormat:@"%C", [currentTime characterAtIndex:[currentTime length]-5]]]; + [portraitHourLabel2 setText:[NSString stringWithFormat:@"%C:", [currentTime characterAtIndex:[currentTime length]-7]]]; + + [secondLabel2 setText:[NSString stringWithFormat:@"%C", [currentTime characterAtIndex:[currentTime length]-1]]]; + [secondLabel1 setText:[NSString stringWithFormat:@"%C", [currentTime characterAtIndex:[currentTime length]-2]]]; + [minuteLabel2 setText:[NSString stringWithFormat:@"%C", [currentTime characterAtIndex:[currentTime length]-4]]]; + [minuteLabel1 setText:[NSString stringWithFormat:@"%C", [currentTime characterAtIndex:[currentTime length]-5]]]; + [hourLabel2 setText:[NSString stringWithFormat:@"%C:", [currentTime characterAtIndex:[currentTime length]-7]]]; + if ([currentTime length] == 8) { + [portraitHourLabel1 setText:[NSString stringWithFormat:@"%C", [currentTime characterAtIndex:0]]]; + [hourLabel1 setText:[NSString stringWithFormat:@"%C", [currentTime characterAtIndex:0]]]; + } else { + [portraitHourLabel1 setText:@""]; + [hourLabel1 setText:@""]; + } + + NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; + [dateFormatter setLocale:usLocale]; + [usLocale release]; + [dateFormatter setDateFormat:@"e"]; + + NSString *weekday = [dateFormatter stringFromDate:[NSDate date]]; + +// portraitSunLabel.hidden = YES; +// portraitMonLabel.hidden = YES; +// portraitTueLabel.hidden = YES; +// portraitWedLabel.hidden = YES; +// portraitThuLabel.hidden = YES; +// portraitFriLabel.hidden = YES; +// portraitSatLabel.hidden = YES; + + sunLabel.hidden = YES; + monLabel.hidden = YES; + tueLabel.hidden = YES; + wedLabel.hidden = YES; + thuLabel.hidden = YES; + friLabel.hidden = YES; + satLabel.hidden = YES; + + if ([weekday isEqualToString:@"1"]) { +// portraitSunLabel.hidden = NO; + sunLabel.hidden = NO; + } else if ([weekday isEqualToString:@"2"]) { +// portraitMonLabel.hidden = NO; + monLabel.hidden = NO; + } else if ([weekday isEqualToString:@"3"]) { +// portraitTueLabel.hidden = NO; + tueLabel.hidden = NO; + } else if ([weekday isEqualToString:@"4"]) { +// portraitWedLabel.hidden = NO; + wedLabel.hidden = NO; + } else if ([weekday isEqualToString:@"5"]) { +// portraitThuLabel.hidden = NO; + thuLabel.hidden = NO; + } else if ([weekday isEqualToString:@"6"]) { +// portraitFriLabel.hidden = NO; + friLabel.hidden = NO; + } else if ([weekday isEqualToString:@"7"]) { +// portraitSatLabel.hidden = NO; + satLabel.hidden = NO; + } + + [dateFormatter setDateFormat:@"a"]; + NSString *ampm = [dateFormatter stringFromDate:[NSDate date]]; + +// portraitAmLabel.hidden = YES; + amLabel.hidden = YES; + +// portraitPmLabel.hidden = YES; + pmLabel.hidden = YES; + + if (![[[NSCalendar currentCalendar] locale] timeIs24HourFormat]) + { + if ([ampm isEqualToString:@"AM"]) { +// portraitAmLabel.hidden = NO; + amLabel.hidden = NO; + } else if ([ampm isEqualToString:@"PM"]) { +// portraitPmLabel.hidden = NO; + pmLabel.hidden = NO; + } + } +} +/* +- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated +{ + if ([viewController class] == [UINavigationController class]) + { NSLog(@"navigation controller!"); + } else { + NSLog(@"not a navigation controller"); + } + NSLog(@"did show a view controller, resizing to %f, %f", viewController.view.frame.size.width, viewController.view.frame.size.height); + [popoverController setPopoverContentSize:viewController.view.frame.size animated:NO]; +} +*/ +- (IBAction)infoButtonTapped:(id)sender +{ + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + // The device is an iPad running iPhone 3.2 or later. + if (!alarmPopoverController) + { +// alarmPopoverController = [[UIPopoverController alloc] initWithContentViewController:mainDelegate.alarmSettingsNavigationController]; + alarmPopoverController = [[UIPopoverController alloc] initWithContentViewController:mainDelegate.tabBarController]; + CGSize size = ((AlarmSettingsViewController *)[mainDelegate.alarmSettingsNavigationController.viewControllers objectAtIndex:0]).view.frame.size; + size.height += 37.0; // For some reason, only here, we have to add 37 pixels to the height. It has something to do with the navigation controller. + size.width = 320.0; + [alarmPopoverController setPopoverContentSize:size]; + } + [alarmPopoverController presentPopoverFromRect:[sender frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; + } else { + // The device is an iPhone or iPod touch. + [mainDelegate flipToSettings]; + } +} + +- (IBAction)sleepTimerButtonTapped:(id)sender +{ + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + + // The device is an iPad running iPhone 3.2 or later. + if (!sleepTimerPopoverController) + { + sleepTimerPopoverController = [[UIPopoverController alloc] initWithContentViewController:mainDelegate.sleepTimerSettingsNavigationController]; + CGSize size = ((SleepTimerSettingsViewController *)[mainDelegate.sleepTimerSettingsNavigationController.viewControllers objectAtIndex:0]).view.frame.size; + size.height += 37; // For some reason, only here, we have to add 37 pixels to the height. It has something to do with the navigation controller. + [sleepTimerPopoverController setPopoverContentSize:size]; + } + + [sleepTimerPopoverController presentPopoverFromRect:[sender frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; +} + +-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + UITouch *touch = [touches anyObject]; + NSUInteger tapCount = [touch tapCount]; + switch (tapCount) { + case 2: + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:1.0]; + + if (self.view.alpha == 1.0) + { + self.view.alpha = 0.25; + } else { + self.view.alpha = 1.0; + } + [UIView commitAnimations]; + + break; + default: + break; + } +} + +// Override to allow orientations other than the default portrait orientation. + - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations + + return YES; +} + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + + +- (void)dealloc { + [alarmPopoverController release]; + [sleepTimerPopoverController release]; + [super dealloc]; +} + + +@end diff --git a/DeepSleepPreventer.h b/DeepSleepPreventer.h new file mode 100644 index 0000000..31df3aa --- /dev/null +++ b/DeepSleepPreventer.h @@ -0,0 +1,30 @@ +// +// DeepSleepPreventer.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 10/22/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import + +@class AVAudioPlayer; + +@interface DeepSleepPreventer : NSObject { + AVAudioPlayer *audioPlayer; + NSTimer *preventSleepTimer; + BOOL isPreventingSleep; +} + +@property (nonatomic, retain) AVAudioPlayer *audioPlayer; +@property (nonatomic, retain) NSTimer *preventSleepTimer; +@property (nonatomic, assign) BOOL isPreventingSleep; + ++ (DeepSleepPreventer *)sharedDeepSleepPreventer; + +- (void)playPreventSleepSound; +- (void)setAudioSessionForMediaPlayback; +- (void)startPreventSleep; +- (void)stopPreventSleep; + +@end diff --git a/DeepSleepPreventer.m b/DeepSleepPreventer.m new file mode 100644 index 0000000..59225e6 --- /dev/null +++ b/DeepSleepPreventer.m @@ -0,0 +1,151 @@ +// +// DeepSleepPreventer.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 10/22/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import "DeepSleepPreventer.h" +#import +#import + +static DeepSleepPreventer *sharedDeepSleepPreventer = nil; + +@implementation DeepSleepPreventer + +@synthesize audioPlayer; +@synthesize preventSleepTimer; +@synthesize isPreventingSleep; + ++ (DeepSleepPreventer *)sharedDeepSleepPreventer { + @synchronized(self) { + if (sharedDeepSleepPreventer == nil) + [[self alloc] init]; + } + + return sharedDeepSleepPreventer; +} + +- (id)init +{ + if ((self = [super init])) { + + isPreventingSleep = NO; + + // Set up sound file + // NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"pinkNoise" ofType:@"m4a"]; + // NSURL *fileURL = [NSURL fileURLWithPath:soundFilePath]; + + // Set up audio player with sound file + // self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil]; + self.audioPlayer = [[AVAudioPlayer alloc] initWithData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"silent" ofType:@"mp3"]] error:NULL]; + [audioPlayer retain]; + self.audioPlayer.numberOfLoops = -1; + [self.audioPlayer prepareToPlay]; + + // You may want to set this to 0.0 even if your sound file is silent. + // I don't know exactly if this affects battery life, but it can't hurt. + [self.audioPlayer setVolume:0.0]; + } + return self; +} + ++ (id)allocWithZone:(NSZone *)zone { + @synchronized(self) { + if (sharedDeepSleepPreventer == nil) { + sharedDeepSleepPreventer = [super allocWithZone:zone]; + return sharedDeepSleepPreventer; + } + } + + return nil; +} + +- (id)copyWithZone:(NSZone *)zone { + return self; +} + +- (id)retain { + return self; +} + +- (unsigned)retainCount { + return UINT_MAX; +} + +- (void)release { + // Do nothing. +} + +- (id)autorelease { + return self; +} + + +- (void)playPreventSleepSound { + + NSLog(@"playing the preventer sound"); +// self.audioPlayer.numberOfLoops = -1; + [self.audioPlayer play]; +} + +- (void)setAudioSessionForMediaPlayback { + + // Activate audio session + AudioSessionSetActive(true); + // Set up audio session to prevent iPhone from deep sleeping while playing sounds + UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback; + AudioSessionSetProperty ( + kAudioSessionProperty_AudioCategory, + sizeof (sessionCategory), + &sessionCategory + ); + UInt32 property = 1; +// OSStatus error; + AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(property), &property); +} + +- (void)startPreventSleep { + + if (!isPreventingSleep) + { + [self setAudioSessionForMediaPlayback]; + + // We need to play a sound at least every 10 seconds to keep the iPhone awake. + // We create a new repeating timer, that begins firing now and then every ten seconds. + // Every time it fires, it calls -playPreventSleepSound + /* self.preventSleepTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:0] + interval:10.0 + target:self + selector:@selector(playPreventSleepSound) + userInfo:nil + repeats:YES]; + + // We add this timer to the current run loop + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + [runLoop addTimer:self.preventSleepTimer forMode:NSDefaultRunLoopMode]; + */ + [self playPreventSleepSound]; + + isPreventingSleep = YES; + } +} + +- (void)stopPreventSleep { + +// self.audioPlayer.numberOfLoops = 0; + + [self.audioPlayer stop]; + isPreventingSleep = NO; + +} + +- (void)dealloc { + // memory management + [preventSleepTimer release]; + [audioPlayer release]; + [super dealloc]; +} + +@end diff --git a/GLLevelMeter.h b/GLLevelMeter.h new file mode 100644 index 0000000..257c2a9 --- /dev/null +++ b/GLLevelMeter.h @@ -0,0 +1,65 @@ +/* + + File: GLLevelMeter.h +Abstract: dB meter class for displaying audio power levels using OpenGL + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + + +#import +#import +#import +#import + +#import "LevelMeter.h" + +@interface GLLevelMeter : LevelMeter { + GLint _backingWidth; + GLint _backingHeight; + EAGLContext *_context; + GLuint _viewRenderbuffer, _viewFramebuffer; +} + +@end diff --git a/GLLevelMeter.m b/GLLevelMeter.m new file mode 100644 index 0000000..8a8c1b0 --- /dev/null +++ b/GLLevelMeter.m @@ -0,0 +1,347 @@ +/* + + File: GLLevelMeter.m +Abstract: dB meter class for displaying audio power levels using OpenGL + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + + +#import +#import + +#import "GLLevelMeter.h" + + +@implementation GLLevelMeter + ++ (Class) layerClass +{ + return [CAEAGLLayer class]; +} + +- (BOOL)_createFramebuffer +{ + glGenFramebuffersOES(1, &_viewFramebuffer); + glGenRenderbuffersOES(1, &_viewRenderbuffer); + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); + [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id)self.layer]; + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); + + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_backingWidth); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_backingHeight); + + if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { + NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); + return NO; + } + + return YES; +} + +- (void)_destroyFramebuffer +{ + glDeleteFramebuffersOES(1, &_viewFramebuffer); + _viewFramebuffer = 0; + glDeleteRenderbuffersOES(1, &_viewRenderbuffer); + _viewRenderbuffer = 0; + +} + +- (void)_setupView +{ + // Sets up matrices and transforms for OpenGL ES + glViewport(0, 0, _backingWidth, _backingHeight); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrthof(0, _backingWidth, 0, _backingHeight, -1.0f, 1.0f); + glMatrixMode(GL_MODELVIEW); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} + +- (void)_performInit +{ + _level = 0.; + _numLights = 0; + _numColorThresholds = 3; + _variableLightIntensity = YES; + _bgColor = [[UIColor alloc] initWithRed:0. green:0. blue:0. alpha:0.6]; + _borderColor = [[UIColor alloc] initWithRed:0. green:0. blue:0. alpha:1.]; + _colorThresholds = (LevelMeterColorThreshold*)malloc(3 * sizeof(LevelMeterColorThreshold)); + _colorThresholds[0].maxValue = 0.6; + _colorThresholds[0].color = [[UIColor alloc] initWithRed:0. green:1. blue:0. alpha:1.]; + _colorThresholds[1].maxValue = 0.9; + _colorThresholds[1].color = [[UIColor alloc] initWithRed:1. green:1. blue:0. alpha:1.]; + _colorThresholds[2].maxValue = 1.; + _colorThresholds[2].color = [[UIColor alloc] initWithRed:1. green:0. blue:0. alpha:1.]; + _vertical = ([self frame].size.width < [self frame].size.height) ? YES : NO; + + CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer; + + self.opaque = NO; + eaglLayer.opaque = NO; + + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; + + + _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; + + if(!_context || ![EAGLContext setCurrentContext:_context] || ![self _createFramebuffer]) { + [self release]; + return; + } + + [self _setupView]; +} + +- (void)_drawView +{ + BOOL success = NO; + + if (!_viewFramebuffer) return; + + // Make sure that you are drawing to the current context + [EAGLContext setCurrentContext:_context]; + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer); + + CGColorRef bgc = self.bgColor.CGColor; + + if (CGColorGetNumberOfComponents(bgc) != 4) goto bail; + + const CGFloat *bg_rgba; + + bg_rgba = CGColorGetComponents(bgc); + + glClearColor(0., 0., 0., 0.); + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + + CGRect bds; + + if (_vertical) + { + glTranslatef(0., [self bounds].size.height, 0.); + glScalef(1., -1., 1.); + bds = [self bounds]; + } else { + glTranslatef(0., [self bounds].size.height, 0.); + glRotatef(-90., 0., 0., 1.); + bds = CGRectMake(0., 0., [self bounds].size.height, [self bounds].size.width); + } + + + if (_numLights == 0) + { + int i; + CGFloat currentTop = 0.; + + for (i=0; i<_numColorThresholds; i++) + { + LevelMeterColorThreshold thisThresh = _colorThresholds[i]; + CGFloat val = MIN(thisThresh.maxValue, _level); + + CGRect rect = CGRectMake( + 0, + (bds.size.height) * currentTop, + bds.size.width, + (bds.size.height) * (val - currentTop) + ); + + GLfloat vertices[] = { + CGRectGetMinX(rect), CGRectGetMinY(rect), + CGRectGetMaxX(rect), CGRectGetMinY(rect), + CGRectGetMinX(rect), CGRectGetMaxY(rect), + CGRectGetMaxX(rect), CGRectGetMaxY(rect), + }; + + CGColorRef clr = thisThresh.color.CGColor; + if (CGColorGetNumberOfComponents(clr) != 4) goto bail; + const CGFloat *rgba; + rgba = CGColorGetComponents(clr); + glColor4f(rgba[0], rgba[1], rgba[2], rgba[3]); + + + glVertexPointer(2, GL_FLOAT, 0, vertices); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + + if (_level < thisThresh.maxValue) break; + + currentTop = val; + } + } + else + { + int light_i; + CGFloat lightMinVal = 0.; + CGFloat insetAmount, lightVSpace; + lightVSpace = bds.size.height / (CGFloat)_numLights; + if (lightVSpace < 4.) insetAmount = 0.; + else if (lightVSpace < 8.) insetAmount = 0.5; + else insetAmount = 1.; + + int peakLight = -1; + if (_peakLevel > 0.) + { + peakLight = _peakLevel * _numLights; + if (peakLight >= _numLights) peakLight = _numLights - 1; + } + + for (light_i=0; light_i<_numLights; light_i++) + { + CGFloat lightMaxVal = (CGFloat)(light_i + 1) / (CGFloat)_numLights; + CGFloat lightIntensity; + CGRect lightRect; + UIColor *lightColor; + + if (light_i == peakLight) + { + lightIntensity = 1.; + } else { + lightIntensity = (_level - lightMinVal) / (lightMaxVal - lightMinVal); + lightIntensity = LEVELMETER_CLAMP(0., lightIntensity, 1.); + if ((!_variableLightIntensity) && (lightIntensity > 0.)) lightIntensity = 1.; + } + + lightColor = _colorThresholds[0].color; + int color_i; + for (color_i=0; color_i<(_numColorThresholds-1); color_i++) + { + LevelMeterColorThreshold thisThresh = _colorThresholds[color_i]; + LevelMeterColorThreshold nextThresh = _colorThresholds[color_i + 1]; + if (thisThresh.maxValue <= lightMaxVal) lightColor = nextThresh.color; + } + + lightRect = CGRectMake( + 0., + bds.size.height * ((CGFloat)(light_i) / (CGFloat)_numLights), + bds.size.width, + bds.size.height * (1. / (CGFloat)_numLights) + ); + lightRect = CGRectInset(lightRect, insetAmount, insetAmount); + + GLfloat vertices[] = { + CGRectGetMinX(lightRect), CGRectGetMinY(lightRect), + CGRectGetMaxX(lightRect), CGRectGetMinY(lightRect), + CGRectGetMinX(lightRect), CGRectGetMaxY(lightRect), + CGRectGetMaxX(lightRect), CGRectGetMaxY(lightRect), + }; + + CGColorRef clr = lightColor.CGColor; + if (CGColorGetNumberOfComponents(clr) != 4) goto bail; + const CGFloat *rgba; + rgba = CGColorGetComponents(clr); + + glVertexPointer(2, GL_FLOAT, 0, vertices); + + glColor4f(bg_rgba[0], bg_rgba[1], bg_rgba[2], bg_rgba[3]); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + GLfloat lightAlpha = rgba[3] * lightIntensity; + if ((lightIntensity < 1.) && (lightIntensity > 0.) && (lightAlpha > .8)) lightAlpha = .8; + + glColor4f(rgba[0], rgba[1], rgba[2], lightAlpha); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + lightMinVal = lightMaxVal; + } + } + + success = YES; +bail: + glPopMatrix(); + + glFlush(); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); + [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; +} + + +- (void)layoutSubviews +{ + [EAGLContext setCurrentContext:_context]; + [self _destroyFramebuffer]; + [self _createFramebuffer]; + [self _drawView]; +} + + + +- (void)drawRect:(CGRect)rect +{ + [self _drawView]; +} + +- (void)setNeedsDisplay +{ + [self _drawView]; +} + + +- (void)dealloc +{ + if([EAGLContext currentContext] == _context) { + [EAGLContext setCurrentContext:nil]; + } + + [_context release]; + _context = nil; + + + [super dealloc]; +} + + + + +@end diff --git a/HUDView.h b/HUDView.h new file mode 100644 index 0000000..e759327 --- /dev/null +++ b/HUDView.h @@ -0,0 +1,16 @@ +// +// HUDView.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 10/1/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import + + +@interface HUDView : UIView { + +} + +@end diff --git a/HUDView.m b/HUDView.m new file mode 100644 index 0000000..74f09ea --- /dev/null +++ b/HUDView.m @@ -0,0 +1,142 @@ +// +// HUDView.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 10/1/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import "HUDView.h" +#import +#import +#import + +@implementation HUDView + + +- (id)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { + // Initialization code + } + return self; +} + + +- (void)drawRect:(CGRect)rect { + CGContextRef context = UIGraphicsGetCurrentContext(); + CGContextSetRGBFillColor(context, 0.0,0.0,0.0,1.0); + CGContextFillRect(context, rect); + + +// if ([displayMode isEqualToString:@"iTunes"]) { // if it's really truly positively using iTunes... +// iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; +// +// currentTrackPersistentID = [[[[iTunes currentTrack] persistentID] mutableCopy] retain]; +// NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(refreshArtworkIfNeeded:) userInfo:nil repeats:YES]; +// +// iTunesTrack *track = [iTunes currentTrack]; + MPMediaItemArtwork *mediaItemArtwork = [[MPMusicPlayerController applicationMusicPlayer].nowPlayingItem valueForProperty:MPMediaItemPropertyArtwork]; + + + // Now for the album art... + //NSImage *artwork; + CGSize originalSize = mediaItemArtwork.bounds.size; + CGSize artworkSize; + artworkSize.width = 320.0; + artworkSize.height = artworkSize.width*originalSize.height/originalSize.width; + + UIImage *artworkImage = [mediaItemArtwork imageWithSize:artworkSize]; +// if ([[track artworks] count]) { + if (artworkImage) { +// artwork = [[[track artworks] objectAtIndex:0] data]; + } else { +// artwork = [NSImage imageNamed:@"NoArtwork"]; + } + + [artworkImage drawAtPoint:CGPointMake(0,0)]; + + // first we have to set up the colors for the gradient fill. + CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); + CGFloat colors[] = + { + 0.0, 0.0, 0.0, 0.00, + 0.0, 0.0, 0.0, .25, + 0.0, 0.0, 0.0, .50, + 0.0, 0.0, 0.0, .75, + 0.0, 0.0, 0.0, 1.00, + }; + CGGradientRef gradient = CGGradientCreateWithColorComponents(rgb, colors, NULL, sizeof(colors)/(sizeof(colors[0])*4)); + CGColorSpaceRelease(rgb); + + // now we can actually create the shape and fill it + + CGPoint start, end; + + // CGContextSetRGBFillColor(context, 0, 0, 0.6, 0.1); +// CGContextFillEllipseInRect(context, CGRectMake(0.0, 0.0, 100.0, 100.0)); +// CGContextStrokeEllipseInRect(context, CGRectMake(0.0, 0.0, 100.0, 100.0)); + + // Gradient + CGRect myrect = CGRectMake(0.0, artworkSize.height-25.0, self.frame.size.width, 35.0); + CGContextSaveGState(context); + CGContextClipToRect(context, myrect); + start = CGPointMake(myrect.origin.x, myrect.origin.y + myrect.size.height * 0.25); + end = CGPointMake(myrect.origin.x, myrect.origin.y + myrect.size.height * 0.75); + CGContextDrawLinearGradient(context, gradient, start, end, kCGGradientDrawsBeforeStartLocation); + CGContextRestoreGState(context); + +// NSImage *scaledArtwork = [[[NSImage alloc] initWithSize:NSMakeSize(400, 400)] autorelease]; +// +// NSAffineTransform *at = [NSAffineTransform transform]; +// [artwork setScalesWhenResized:YES]; +// float heightFactor = 400.0/[artwork size].height; +// float widthFactor = 400.0/[artwork size].width; +// float scale; +// if(heightFactor > widthFactor){ +// scale = widthFactor; +// } else { +// scale = heightFactor; +// } +// +// [at scaleBy:scale]; +// +// [scaledArtwork lockFocus]; +// [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationLow]; +// [artwork setSize:[at transformSize:[artwork size]]]; +// [artwork compositeToPoint:NSMakePoint((400-[artwork size].width)/2 , (400-[artwork size].height)/2) operation:NSCompositeCopy]; +// [scaledArtwork unlockFocus]; +// +// NSPoint backgroundCenter; +// backgroundCenter.x = [self bounds].size.width / 2; +// backgroundCenter.y = [self bounds].size.height / 2; +// +// NSPoint drawPoint = backgroundCenter; +// drawPoint.x -= [artwork size].width / 2; +// drawPoint.y -= [artwork size].height / 2; +// +// [scaledArtwork drawAtPoint:drawPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:0.3]; +// +// } else if ([displayMode isEqualToString:@"Dynamite"]) { +// // Draw the dynamite graphic. +// NSImage *dynamite = [NSImage imageNamed:@"dynamite"]; +// +// NSPoint backgroundCenter; +// backgroundCenter.x = [self bounds].size.width / 2; +// backgroundCenter.y = [self bounds].size.height / 2; +// +// NSPoint drawPoint = backgroundCenter; +// drawPoint.x -= [dynamite size].width / 2; +// drawPoint.y -= [dynamite size].height / 2; +// +// [dynamite drawAtPoint:drawPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:0.3]; +// +// } +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/Icon-72.png b/Icon-72.png new file mode 100644 index 0000000..e4a8985 Binary files /dev/null and b/Icon-72.png differ diff --git a/Icon.png b/Icon.png new file mode 100644 index 0000000..ed00b62 Binary files /dev/null and b/Icon.png differ diff --git a/Icon@2x.png b/Icon@2x.png new file mode 100644 index 0000000..d046202 Binary files /dev/null and b/Icon@2x.png differ diff --git a/KeypadView.xib b/KeypadView.xib new file mode 100644 index 0000000..cea3783 --- /dev/null +++ b/KeypadView.xib @@ -0,0 +1,1044 @@ + + + + 784 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 123 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 292 + + YES + + + 256 + {{0, -15}, {320, 260}} + + NO + YES + 4 + YES + IBCocoaTouchFramework + + NSImage + keypadBackground.png + + + + + 292 + {{25, 32}, {80, 41}} + + NO + NO + 7 + IBCocoaTouchFramework + 0 + 0 + + Helvetica-Bold + 18 + 16 + + NO + {0, 1} + 7 + + 1 + MC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMAA + + + + 1 + MSAxIDEgMAA + + + 1 + MSAxIDEAA + + + NSImage + numericButtonPressed.png + + + NSImage + numericButton.png + + + + + 292 + {{25, 81}, {80, 41}} + + NO + NO + 4 + IBCocoaTouchFramework + 0 + 0 + + NO + {0, 1} + 4 + + 1 + MC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMAA + + + + 1 + MSAxIDEgMAA + + + + + + + + 292 + {{25, 130}, {80, 41}} + + NO + NO + 1 + IBCocoaTouchFramework + 0 + 0 + + NO + {0, 1} + 1 + + 1 + MC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMAA + + + + 1 + MSAxIDEgMAA + + + + + + + + 292 + {{120, 32}, {80, 41}} + + NO + NO + 8 + IBCocoaTouchFramework + 0 + 0 + + NO + {0, 1} + 8 + + 1 + MC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMAA + + + + 1 + MSAxIDEgMAA + + + + + + + + 292 + {{120, 81}, {80, 41}} + + NO + NO + 5 + IBCocoaTouchFramework + 0 + 0 + + NO + {0, 1} + 5 + + 1 + MC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMAA + + + + 1 + MSAxIDEgMAA + + + + + + + + 292 + {{120, 130}, {80, 41}} + + NO + NO + 2 + IBCocoaTouchFramework + 0 + 0 + + NO + {0, 1} + 2 + + 1 + MC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMAA + + + + 1 + MSAxIDEgMAA + + + + + + + + 292 + {{120, 179}, {80, 41}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + NO + {0, 1} + 0 + + 1 + MC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMAA + + + + 1 + MSAxIDEgMAA + + + + + + + + 292 + {{215, 32}, {80, 41}} + + NO + NO + 9 + IBCocoaTouchFramework + 0 + 0 + + NO + {0, 1} + 9 + + 1 + MC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMAA + + + + 1 + MSAxIDEgMAA + + + + + + + + 292 + {{215, 81}, {80, 41}} + + NO + NO + 6 + IBCocoaTouchFramework + 0 + 0 + + NO + {0, 1} + 6 + + 1 + MC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMAA + + + + 1 + MSAxIDEgMAA + + + + + + + + 292 + {{215, 130}, {80, 41}} + + NO + NO + 3 + IBCocoaTouchFramework + 0 + 0 + + NO + {0, 1} + 3 + + 1 + MC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMgMC4yMDAwMDAwMDMAA + + + + 1 + MSAxIDEgMAA + + + + + + + + 292 + {{25, 178}, {80, 41}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + Helvetica-Bold + 12 + 16 + + NO + {0, -1} + DONE + + 3 + MQA + + + + 1 + MC4xNTUwNDEyMTMzIDAuMTkzODcxNzEzMyAwLjU0NTkxODM2NzMAA + + + 1 + MC4xNTUwNDEyMTMzIDAuMTkzODcxNzEzMyAwLjU0NTkxODM2NzMAA + + + NSImage + numericBlueButtonPressed.png + + + NSImage + numericBlueButton.png + + + + + 292 + {{215, 178}, {80, 41}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + NO + {0, -1} + C + + + + 1 + MCAwIDAgMAA + + + 1 + MCAwIDAAA + + + NSImage + numericRedButtonPressed.png + + + NSImage + numericRedButton.png + + + + {320, 230} + + + 3 + MSAwAA + + NO + NO + + 3 + + IBCocoaTouchFramework + + + + + YES + + + view + + + + 19 + + + + enterDigit: + + + 7 + + 20 + + + + enterDigit: + + + 7 + + 21 + + + + enterDigit: + + + 7 + + 22 + + + + enterDigit: + + + 7 + + 23 + + + + enterDigit: + + + 7 + + 24 + + + + enterDigit: + + + 7 + + 25 + + + + enterDigit: + + + 7 + + 26 + + + + enterDigit: + + + 7 + + 27 + + + + enterDigit: + + + 7 + + 28 + + + + enterDigit: + + + 7 + + 29 + + + + clearDigits: + + + 7 + + 30 + + + + doneButtonTapped: + + + 7 + + 31 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 4 + + + YES + + + + + + + + + + + + + + + + Keypad view + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + 10 + + + + + 11 + + + + + 12 + + + + + 13 + + + + + 14 + + + + + 15 + + + + + 16 + + + + + 17 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 10.IBPluginDependency + 11.IBPluginDependency + 12.IBPluginDependency + 13.IBPluginDependency + 14.IBPluginDependency + 15.IBPluginDependency + 16.IBPluginDependency + 17.IBPluginDependency + 4.IBEditorWindowLastContentRect + 4.IBPluginDependency + 5.IBPluginDependency + 7.IBPluginDependency + 8.IBPluginDependency + 9.IBPluginDependency + + + YES + KeypadViewController + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + {{379, 372}, {320, 230}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 31 + + + + YES + + KeypadViewController + UIViewController + + YES + + YES + clearDigits: + doneButtonTapped: + enterDigit: + + + YES + id + id + id + + + + YES + + YES + clearDigits: + doneButtonTapped: + enterDigit: + + + YES + + clearDigits: + id + + + doneButtonTapped: + id + + + enterDigit: + id + + + + + delegate + id + + + delegate + + delegate + id + + + + IBProjectSource + KeypadViewController.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + MediaPlayer.framework/Headers/MPMoviePlayerViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + YES + + YES + keypadBackground.png + numericBlueButton.png + numericBlueButtonPressed.png + numericButton.png + numericButtonPressed.png + numericRedButton.png + numericRedButtonPressed.png + + + YES + {320, 230} + {80, 41} + {80, 41} + {80, 41} + {80, 41} + {80, 41} + {80, 41} + + + 123 + + diff --git a/KeypadViewController.h b/KeypadViewController.h new file mode 100644 index 0000000..7939d7d --- /dev/null +++ b/KeypadViewController.h @@ -0,0 +1,25 @@ +// +// KeypadViewController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 7/14/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import + + +@interface KeypadViewController : UIViewController { + + id delegate; + +} + +@property (nonatomic, assign) id delegate; + + +- (IBAction)enterDigit:(id)sender; +- (IBAction)clearDigits:(id)sender; +- (IBAction)doneButtonTapped:(id)sender; + +@end diff --git a/KeypadViewController.m b/KeypadViewController.m new file mode 100644 index 0000000..062c38c --- /dev/null +++ b/KeypadViewController.m @@ -0,0 +1,94 @@ +// +// KeypadViewController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 7/14/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "KeypadViewController.h" + + +@implementation KeypadViewController + +@synthesize delegate; + +- (IBAction)clearDigits:(id)sender +{ + [delegate clearDigits:sender]; +} + +- (IBAction)enterDigit:(id)sender +{ + [delegate enterDigit:sender]; +} + +- (IBAction)doneButtonTapped:(id)sender +{ + [delegate toggleKeypad:sender]; +} + +- (void)viewDidAppear:(BOOL)animated +{ + CGRect frame = self.view.frame; + frame.origin.y = 400; + self.view.frame = frame; + + NSLog(@"y: %f", self.view.frame.origin.y); + +} + +- (void)viewDidLoad +{ + CGRect frame = self.view.frame; + frame.origin.y = 400; + self.view.frame = frame; + + NSLog(@"loaded the keypad"); +} + +/* + // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { + // Custom initialization + } + return self; +} +*/ + +/* +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad { + [super viewDidLoad]; +} +*/ + +/* +// Override to allow orientations other than the default portrait orientation. +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations + return (interfaceOrientation == UIInterfaceOrientationPortrait); +} +*/ + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + [super viewDidUnload]; + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/LevelMeter.h b/LevelMeter.h new file mode 100644 index 0000000..2bfa0d5 --- /dev/null +++ b/LevelMeter.h @@ -0,0 +1,103 @@ +/* + + File: LevelMeter.h +Abstract: Base level metering class + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + + +#import + +#ifndef LEVELMETER_CLAMP +#define LEVELMETER_CLAMP(min,x,max) (x < min ? min : (x > max ? max : x)) +#endif + +// The LevelMeterColorThreshold struct is used to define the colors for the LevelMeter, +// and at what values each of those colors begins. +typedef struct LevelMeterColorThreshold { + CGFloat maxValue; // A value from 0 - 1. The maximum value shown in this color + UIColor *color; // A UIColor to be used for this value range +} LevelMeterColorThreshold; + +@interface LevelMeter : UIView { + NSUInteger _numLights; + CGFloat _level, _peakLevel; + LevelMeterColorThreshold *_colorThresholds; + NSUInteger _numColorThresholds; + BOOL _vertical; + BOOL _variableLightIntensity; + UIColor *_bgColor, *_borderColor; +} + +// The current level, from 0 - 1 +@property CGFloat level; + +// Optional peak level, will be drawn if > 0 +@property CGFloat peakLevel; + +// The number of lights to show, or 0 to show a continuous bar +@property NSUInteger numLights; + +// Whether the view is oriented V or H. This is initially automatically set based on the +// aspect ratio of the view. +@property(getter=isVertical) BOOL vertical; + +// Whether to use variable intensity lights. Has no effect if numLights == 0. +@property BOOL variableLightIntensity; + +// The background color of the lights +@property(retain) UIColor *bgColor; + +// The border color of the lights +@property(retain) UIColor *borderColor; + +// Returns a pointer to the first LevelMeterColorThreshold struct. The number of color +// thresholds is returned in count +- (LevelMeterColorThreshold *)colorThresholds:(NSUInteger *)count; + +// Load elements from and use these as our color threshold values. +- (void)setColorThresholds:(LevelMeterColorThreshold *)thresholds count:(NSUInteger)count; + +@end diff --git a/LevelMeter.m b/LevelMeter.m new file mode 100644 index 0000000..3629035 --- /dev/null +++ b/LevelMeter.m @@ -0,0 +1,293 @@ +/* + + File: LevelMeter.m +Abstract: Base level metering class + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + + +#import "LevelMeter.h" + + +int _cmp_levelThresholds(const void * a, const void * b) +{ + if (((LevelMeterColorThreshold *)a)->maxValue > ((LevelMeterColorThreshold *)b)->maxValue) return 1; + if (((LevelMeterColorThreshold *)a)->maxValue < ((LevelMeterColorThreshold *)b)->maxValue) return -1; + return 0; +} + + +@implementation LevelMeter + +@synthesize vertical = _vertical; +@synthesize bgColor = _bgColor; +@synthesize borderColor = _borderColor; +@synthesize variableLightIntensity = _variableLightIntensity; + +- (void)_performInit +{ + _level = 0.; + _numLights = 0; + _numColorThresholds = 3; + _variableLightIntensity = YES; + _bgColor = [[UIColor alloc] initWithRed:0. green:0. blue:0. alpha:0.6]; + _borderColor = [[UIColor alloc] initWithRed:0. green:0. blue:0. alpha:1.]; + _colorThresholds = malloc(3 * sizeof(LevelMeterColorThreshold)); + _colorThresholds[0].maxValue = 0.25; + _colorThresholds[0].color = [[UIColor alloc] initWithRed:0. green:1. blue:0. alpha:1.]; + _colorThresholds[1].maxValue = 0.8; + _colorThresholds[1].color = [[UIColor alloc] initWithRed:1. green:1. blue:0. alpha:1.]; + _colorThresholds[2].maxValue = 1.; + _colorThresholds[2].color = [[UIColor alloc] initWithRed:1. green:0. blue:0. alpha:1.]; + _vertical = ([self frame].size.width < [self frame].size.height) ? YES : NO; +} + + +- (id)initWithFrame:(CGRect)frame +{ + if (self = [super initWithFrame:frame]) { + [self _performInit]; + } + return self; +} + + +- (id)initWithCoder:(NSCoder *)coder +{ + if (self = [super initWithCoder:coder]) { + [self _performInit]; + } + return self; +} + + +- (void)drawRect:(CGRect)rect +{ + CGColorSpaceRef cs = NULL; + CGContextRef cxt = NULL; + CGRect bds; + + cxt = UIGraphicsGetCurrentContext(); + cs = CGColorSpaceCreateDeviceRGB(); + + if (_vertical) + { + CGContextTranslateCTM(cxt, 0., [self bounds].size.height); + CGContextScaleCTM(cxt, 1., -1.); + bds = [self bounds]; + } else { + CGContextTranslateCTM(cxt, 0., [self bounds].size.height); + CGContextRotateCTM(cxt, -M_PI_2); + bds = CGRectMake(0., 0., [self bounds].size.height, [self bounds].size.width); + } + + CGContextSetFillColorSpace(cxt, cs); + CGContextSetStrokeColorSpace(cxt, cs); + + if (_numLights == 0) + { + int i; + CGFloat currentTop = 0.; + + if (_bgColor) + { + [_bgColor set]; + CGContextFillRect(cxt, bds); + } + + for (i=0; i<_numColorThresholds; i++) + { + LevelMeterColorThreshold thisThresh = _colorThresholds[i]; + CGFloat val = MIN(thisThresh.maxValue, _level); + + CGRect rect = CGRectMake( + 0, + (bds.size.height) * currentTop, + bds.size.width, + (bds.size.height) * (val - currentTop) + ); + + [thisThresh.color set]; + CGContextFillRect(cxt, rect); + + if (_level < thisThresh.maxValue) break; + + currentTop = val; + } + + if (_borderColor) + { + [_borderColor set]; + CGContextStrokeRect(cxt, CGRectInset(bds, .5, .5)); + } + + } else { + int light_i; + CGFloat lightMinVal = 0.; + CGFloat insetAmount, lightVSpace; + lightVSpace = bds.size.height / (CGFloat)_numLights; + if (lightVSpace < 4.) insetAmount = 0.; + else if (lightVSpace < 8.) insetAmount = 0.5; + else insetAmount = 1.; + + int peakLight = -1; + if (_peakLevel > 0.) + { + peakLight = _peakLevel * _numLights; + if (peakLight >= _numLights) peakLight = _numLights - 1; + } + + for (light_i=0; light_i<_numLights; light_i++) + { + CGFloat lightMaxVal = (CGFloat)(light_i + 1) / (CGFloat)_numLights; + CGFloat lightIntensity; + CGRect lightRect; + UIColor *lightColor; + + if (light_i == peakLight) + { + lightIntensity = 1.; + } else { + lightIntensity = (_level - lightMinVal) / (lightMaxVal - lightMinVal); + lightIntensity = LEVELMETER_CLAMP(0., lightIntensity, 1.); + if ((!_variableLightIntensity) && (lightIntensity > 0.)) lightIntensity = 1.; + } + + lightColor = _colorThresholds[0].color; + int color_i; + for (color_i=0; color_i<(_numColorThresholds-1); color_i++) + { + LevelMeterColorThreshold thisThresh = _colorThresholds[color_i]; + LevelMeterColorThreshold nextThresh = _colorThresholds[color_i + 1]; + if (thisThresh.maxValue <= lightMaxVal) lightColor = nextThresh.color; + } + + lightRect = CGRectMake( + 0., + bds.size.height * ((CGFloat)(light_i) / (CGFloat)_numLights), + bds.size.width, + bds.size.height * (1. / (CGFloat)_numLights) + ); + lightRect = CGRectInset(lightRect, insetAmount, insetAmount); + + if (_bgColor) + { + [_bgColor set]; + CGContextFillRect(cxt, lightRect); + } + + if (lightIntensity == 1.) + { + [lightColor set]; + CGContextFillRect(cxt, lightRect); + } else if (lightIntensity > 0.) { + CGColorRef clr = CGColorCreateCopyWithAlpha([lightColor CGColor], lightIntensity); + CGContextSetFillColorWithColor(cxt, clr); + CGContextFillRect(cxt, lightRect); + CGColorRelease(clr); + } + + if (_borderColor) + { + [_borderColor set]; + CGContextStrokeRect(cxt, CGRectInset(lightRect, 0.5, 0.5)); + } + + lightMinVal = lightMaxVal; + } + + } + + CGColorSpaceRelease(cs); +} + + +- (void)dealloc { + int i; + for (i=0; i<_numColorThresholds; i++) [_colorThresholds[i].color release]; + free(_colorThresholds); + + [_bgColor release]; + [_borderColor release]; + + [super dealloc]; +} + + +- (CGFloat)level { return _level; } +- (void)setLevel:(CGFloat)v { _level = v; } + +- (CGFloat)peakLevel { return _peakLevel; } +- (void)setPeakLevel:(CGFloat)v { _peakLevel = v; } + +- (NSUInteger)numLights { return _numLights; } +- (void)setNumLights:(NSUInteger)v { _numLights = v; } + +- (LevelMeterColorThreshold *)colorThresholds:(NSUInteger *)count +{ + *count = _numColorThresholds; + return _colorThresholds; +} + +- (void)setColorThresholds:(LevelMeterColorThreshold *)thresholds count:(NSUInteger)count +{ + int i; + for (i=0; i<_numColorThresholds; i++) [_colorThresholds[i].color release]; + _colorThresholds = realloc(_colorThresholds, sizeof(LevelMeterColorThreshold) * count); + + for (i=0; i + + + 1024 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 123 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + IBIPadFramework + + + + 1316 + + {768, 1024} + + 1 + MCAwIDAAA + + NO + NO + + 2 + + IBIPadFramework + YES + YES + + + IBIPadFramework + + + + 292 + + YES + + + 256 + {1024, 768} + + NO + YES + YES + IBIPadFramework + + NSImage + clockView-iPad.png + + + + + 265 + {{974, 718}, {40, 40}} + + NO + 10 + IBIPadFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + + 3 + MQA + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + NSImage + info.png + + + + + 292 + {{118, 189}, {161, 333}} + + NO + YES + NO + IBIPadFramework + 0 + + DS-Digital-Italic + 288 + 16 + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + 292 + {{214, 189}, {241, 333}} + + NO + YES + NO + IBIPadFramework + 0: + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + {0, 0} + 1 + 10 + 2 + + + + 292 + {{449, 189}, {161, 333}} + + NO + YES + NO + IBIPadFramework + 0 + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + 292 + {{584, 189}, {161, 333}} + + NO + YES + NO + IBIPadFramework + 0 + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + 292 + {{746, 339}, {81, 167}} + + NO + YES + NO + IBIPadFramework + 0 + + DS-Digital-Italic + 144 + 16 + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + 292 + {{719, 338}, {41, 167}} + + NO + YES + NO + IBIPadFramework + : + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + 292 + {{815, 339}, {81, 167}} + + NO + NO + IBIPadFramework + 0 + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + -2147483356 + {{277, 569}, {65, 47}} + + NO + YES + NO + IBIPadFramework + sun + + DS-Digital-Italic + 40 + 16 + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{353, 569}, {78, 47}} + + NO + YES + NO + IBIPadFramework + mon + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{772, 275}, {78, 66}} + + NO + YES + NO + IBIPadFramework + am + + DS-Digital-Italic + 56 + 16 + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{851, 275}, {78, 66}} + + NO + YES + NO + IBIPadFramework + pm + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{428, 570}, {56, 47}} + + NO + YES + NO + IBIPadFramework + tue + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{503, 569}, {74, 47}} + + NO + YES + NO + IBIPadFramework + wed + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{577, 570}, {56, 47}} + + NO + YES + NO + IBIPadFramework + thu + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{652, 569}, {49, 47}} + + NO + YES + NO + IBIPadFramework + fri + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{716, 570}, {54, 47}} + + NO + YES + NO + IBIPadFramework + sat + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + 256 + {{110, 39}, {75, 75}} + + NO + YES + YES + IBIPadFramework + + NSImage + bell-iPad.png + + + + {1024, 768} + + + 1 + MCAwLjcwMzAxODUxODEgMSAwAA + + 0.0 + + 3 + + IBIPadFramework + + + + + YES + + + delegate + + + + 5 + + + + window + + + + 47 + + + + clockViewController + + + + 51 + + + + view + + + + 53 + + + + infoButtonTapped: + + + 7 + + 145 + + + + alarmBell + + + + 147 + + + + backgroundImageView + + + + 148 + + + + hourLabel1 + + + + 149 + + + + hourLabel2 + + + + 150 + + + + minuteLabel1 + + + + 151 + + + + minuteLabel2 + + + + 152 + + + + colonLabel + + + + 153 + + + + secondLabel1 + + + + 154 + + + + secondLabel2 + + + + 155 + + + + amLabel + + + + 156 + + + + pmLabel + + + + 157 + + + + rightSettingsButton + + + + 158 + + + + satLabel + + + + 159 + + + + friLabel + + + + 160 + + + + thuLabel + + + + 161 + + + + wedLabel + + + + 162 + + + + tueLabel + + + + 163 + + + + monLabel + + + + 164 + + + + sunLabel + + + + 165 + + + + + YES + + 0 + + + + + + 2 + + + + + -1 + + + File's Owner + + + 4 + + + App Delegate + + + -2 + + + + + 6 + + + + + 52 + + + YES + + + + + + + + + + + + + + + + + + + + + + + + 125 + + + + + 126 + + + + + 127 + + + + + 128 + + + + + 129 + + + + + 130 + + + + + 131 + + + + + 132 + + + + + 133 + + + + + 134 + + + + + 135 + + + + + 136 + + + + + 137 + + + + + 138 + + + + + 139 + + + + + 140 + + + + + 141 + + + + + 142 + + + + + 143 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 126.IBPluginDependency + 127.CustomClassName + 127.IBPluginDependency + 128.CustomClassName + 128.IBPluginDependency + 129.CustomClassName + 129.IBPluginDependency + 130.CustomClassName + 130.IBPluginDependency + 131.CustomClassName + 131.IBPluginDependency + 132.CustomClassName + 132.IBPluginDependency + 133.CustomClassName + 133.IBPluginDependency + 134.CustomClassName + 134.IBPluginDependency + 135.CustomClassName + 135.IBPluginDependency + 136.CustomClassName + 136.IBPluginDependency + 137.CustomClassName + 137.IBPluginDependency + 138.CustomClassName + 138.IBPluginDependency + 139.CustomClassName + 139.IBPluginDependency + 140.CustomClassName + 140.IBPluginDependency + 141.CustomClassName + 141.IBPluginDependency + 142.CustomClassName + 142.IBPluginDependency + 2.IBAttributePlaceholdersKey + 2.IBEditorWindowLastContentRect + 2.IBPluginDependency + 2.UIWindow.visibleAtLaunch + 4.CustomClassName + 4.IBPluginDependency + 52.CustomClassName + 52.IBEditorWindowLastContentRect + 52.IBPluginDependency + 6.CustomClassName + 6.IBPluginDependency + + + YES + UIApplication + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + YES + + + YES + + + {{497, 4}, {783, 752}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + Sleep_Blaster_touchAppDelegate + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ClockView + {{0, 4}, {1039, 752}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ClockViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 166 + + + + YES + + ClockView + UIView + + IBProjectSource + ClockView.h + + + + ClockViewController + UIViewController + + YES + + YES + infoButtonTapped: + sleepTimerButtonTapped: + + + YES + id + id + + + + YES + + YES + infoButtonTapped: + sleepTimerButtonTapped: + + + YES + + infoButtonTapped: + id + + + sleepTimerButtonTapped: + id + + + + + YES + + YES + alarmBell + amLabel + backgroundImageView + colonLabel + friLabel + hourLabel1 + hourLabel2 + landscapeClockBackgroundView + minuteLabel1 + minuteLabel2 + monLabel + pmLabel + portraitAlarmBell + portraitAmLabel + portraitClockBackgroundView + portraitColonLabel + portraitFriLabel + portraitHourLabel1 + portraitHourLabel2 + portraitMinuteLabel1 + portraitMinuteLabel2 + portraitMonLabel + portraitPmLabel + portraitSatLabel + portraitSecondLabel1 + portraitSecondLabel2 + portraitSunLabel + portraitThuLabel + portraitTueLabel + portraitWedLabel + rightSettingsButton + satLabel + secondLabel1 + secondLabel2 + sunLabel + thuLabel + tueLabel + wedLabel + window + + + YES + UIImageView + ShadowedLabel + UIImageView + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + UIView + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + UIImageView + ShadowedLabel + UIView + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + UIButton + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + UIWindow + + + + YES + + YES + alarmBell + amLabel + backgroundImageView + colonLabel + friLabel + hourLabel1 + hourLabel2 + landscapeClockBackgroundView + minuteLabel1 + minuteLabel2 + monLabel + pmLabel + portraitAlarmBell + portraitAmLabel + portraitClockBackgroundView + portraitColonLabel + portraitFriLabel + portraitHourLabel1 + portraitHourLabel2 + portraitMinuteLabel1 + portraitMinuteLabel2 + portraitMonLabel + portraitPmLabel + portraitSatLabel + portraitSecondLabel1 + portraitSecondLabel2 + portraitSunLabel + portraitThuLabel + portraitTueLabel + portraitWedLabel + rightSettingsButton + satLabel + secondLabel1 + secondLabel2 + sunLabel + thuLabel + tueLabel + wedLabel + window + + + YES + + alarmBell + UIImageView + + + amLabel + ShadowedLabel + + + backgroundImageView + UIImageView + + + colonLabel + ShadowedLabel + + + friLabel + ShadowedLabel + + + hourLabel1 + ShadowedLabel + + + hourLabel2 + ShadowedLabel + + + landscapeClockBackgroundView + UIView + + + minuteLabel1 + ShadowedLabel + + + minuteLabel2 + ShadowedLabel + + + monLabel + ShadowedLabel + + + pmLabel + ShadowedLabel + + + portraitAlarmBell + UIImageView + + + portraitAmLabel + ShadowedLabel + + + portraitClockBackgroundView + UIView + + + portraitColonLabel + ShadowedLabel + + + portraitFriLabel + ShadowedLabel + + + portraitHourLabel1 + ShadowedLabel + + + portraitHourLabel2 + ShadowedLabel + + + portraitMinuteLabel1 + ShadowedLabel + + + portraitMinuteLabel2 + ShadowedLabel + + + portraitMonLabel + ShadowedLabel + + + portraitPmLabel + ShadowedLabel + + + portraitSatLabel + ShadowedLabel + + + portraitSecondLabel1 + ShadowedLabel + + + portraitSecondLabel2 + ShadowedLabel + + + portraitSunLabel + ShadowedLabel + + + portraitThuLabel + ShadowedLabel + + + portraitTueLabel + ShadowedLabel + + + portraitWedLabel + ShadowedLabel + + + rightSettingsButton + UIButton + + + satLabel + ShadowedLabel + + + secondLabel1 + ShadowedLabel + + + secondLabel2 + ShadowedLabel + + + sunLabel + ShadowedLabel + + + thuLabel + ShadowedLabel + + + tueLabel + ShadowedLabel + + + wedLabel + ShadowedLabel + + + window + UIWindow + + + + + IBProjectSource + ClockViewController.h + + + + ShadowedLabel + UILabel + + IBProjectSource + Classes/ShadowedLabel.h + + + + Sleep_Blaster_touchAppDelegate + NSObject + + YES + + YES + flipToClockView: + loadSongsAsynchronously: + + + YES + id + id + + + + YES + + YES + flipToClockView: + loadSongsAsynchronously: + + + YES + + flipToClockView: + id + + + loadSongsAsynchronously: + id + + + + + YES + + YES + clockViewController + tabBarController + window + + + YES + ClockViewController + UITabBarController + UIWindow + + + + YES + + YES + clockViewController + tabBarController + window + + + YES + + clockViewController + ClockViewController + + + tabBarController + UITabBarController + + + window + UIWindow + + + + + IBProjectSource + Classes/Sleep_Blaster_touchAppDelegate.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIApplication + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIApplication.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UITabBarController + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + MediaPlayer.framework/Headers/MPMoviePlayerViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + UIWindow + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIWindow.h + + + + + 0 + IBIPadFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + YES + + YES + bell-iPad.png + clockView-iPad.png + info.png + + + YES + {75, 75} + {1024, 768} + {20, 20} + + + 123 + + diff --git a/MainWindow.xib b/MainWindow.xib new file mode 100644 index 0000000..1966bbe --- /dev/null +++ b/MainWindow.xib @@ -0,0 +1,2292 @@ + + + + 784 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 123 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + IBCocoaTouchFramework + + + + 1316 + + {320, 480} + + 1 + MCAwIDAAA + + NO + NO + + IBCocoaTouchFramework + YES + YES + + + + 292 + + YES + + + 256 + {480, 320} + + NO + YES + 1 + YES + IBCocoaTouchFramework + + NSImage + ClockView.png + + + + + 292 + {{36, 50}, {81, 167}} + + NO + YES + NO + IBCocoaTouchFramework + 0 + + DS-Digital-Italic + 144 + 16 + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + 292 + {{88, 50}, {121, 167}} + + NO + YES + NO + IBCocoaTouchFramework + 0: + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + {0, 0} + 1 + 10 + 2 + + + + 292 + {{205, 50}, {81, 167}} + + NO + YES + NO + IBCocoaTouchFramework + 0 + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + 292 + {{275, 50}, {81, 167}} + + NO + YES + NO + IBCocoaTouchFramework + 0 + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + 292 + {{364, 125}, {41, 84}} + + NO + YES + NO + IBCocoaTouchFramework + 0 + + DS-Digital-Italic + 72 + 16 + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + 292 + {{348, 124}, {21, 84}} + + NO + YES + NO + IBCocoaTouchFramework + : + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + 292 + {{399, 125}, {41, 84}} + + NO + YES + NO + IBCocoaTouchFramework + 0 + + + 1 + MC40MDM5MjE1NzQ0IDAuODI3NDUwOTkwNyAwLjg5ODAzOTIyMTgAA + + + 1 + 10 + 2 + + + + -2147483356 + {{130, 235}, {33, 24}} + + NO + YES + NO + IBCocoaTouchFramework + sun + + DS-Digital-Italic + 20 + 16 + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{166, 235}, {39, 24}} + + NO + YES + NO + IBCocoaTouchFramework + mon + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{391, 96}, {39, 34}} + + NO + YES + NO + IBCocoaTouchFramework + am + + DS-Digital-Italic + 28 + 16 + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{430, 96}, {39, 34}} + + NO + YES + NO + IBCocoaTouchFramework + pm + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{203, 235}, {28, 24}} + + NO + YES + NO + IBCocoaTouchFramework + tue + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{241, 235}, {37, 24}} + + NO + YES + NO + IBCocoaTouchFramework + wed + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{279, 235}, {31, 24}} + + NO + YES + NO + IBCocoaTouchFramework + thu + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{317, 235}, {24, 24}} + + NO + YES + NO + IBCocoaTouchFramework + fri + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + -2147483356 + {{349, 235}, {30, 24}} + + NO + YES + NO + IBCocoaTouchFramework + sat + + + 1 + MC4yODYyNzQ1MjI1IDAuNzQ5MDE5NjIyOCAwLjE0MTE3NjQ3NzEAA + + + 1 + 10 + + + + 292 + {{48, 62}, {31, 30}} + + NO + YES + YES + IBCocoaTouchFramework + + NSImage + bell.png + + + + + 265 + {{440, 280}, {40, 40}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + YES + + 3 + MQA + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + 3 + MC41AA + + + NSImage + info.png + + + + {480, 320} + + + 1 + MC4wMDIwMDAxNjA2OTUgMC41MTUzMDYxMjI0IDAuMDQyODc0OTgyNzcgMAA + + NO + 0.0 + + 3 + + IBCocoaTouchFramework + + + IBCocoaTouchFramework + + + + + NO + + + 2 + + + 1 + + IBCocoaTouchFramework + NO + + + Alarm Clock + + NSImage + clockIcon.png + + IBCocoaTouchFramework + + + + + 1 + + IBCocoaTouchFramework + NO + + + 256 + {320, 44} + NO + YES + YES + IBCocoaTouchFramework + 2 + + + YES + + + + Alarm Settings + + Done + IBCocoaTouchFramework + 1 + + + IBCocoaTouchFramework + + + + 1 + + IBCocoaTouchFramework + NO + + + + + YES + + + + Sleep Timer + + NSImage + hourGlassIcon.png + + IBCocoaTouchFramework + + + + SleepTimerSettingsView + + 1 + + IBCocoaTouchFramework + NO + + + + + 266 + {{129, 330}, {163, 49}} + + 3 + MCAwAA + + NO + IBCocoaTouchFramework + + + + + + YES + + + delegate + + + + 5 + + + + window + + + + 6 + + + + clockViewController + + + + 49 + + + + view + + + + 50 + + + + infoButtonTapped: + + + 7 + + 140 + + + + backgroundImageView + + + + 141 + + + + alarmBell + + + + 142 + + + + hourLabel1 + + + + 143 + + + + hourLabel2 + + + + 144 + + + + minuteLabel1 + + + + 145 + + + + minuteLabel2 + + + + 146 + + + + colonLabel + + + + 147 + + + + secondLabel1 + + + + 148 + + + + secondLabel2 + + + + 149 + + + + amLabel + + + + 150 + + + + pmLabel + + + + 151 + + + + sunLabel + + + + 152 + + + + monLabel + + + + 153 + + + + tueLabel + + + + 154 + + + + wedLabel + + + + 155 + + + + thuLabel + + + + 156 + + + + friLabel + + + + 157 + + + + satLabel + + + + 158 + + + + rightSettingsButton + + + + 159 + + + + + YES + + 0 + + + + + + 2 + + + + + -1 + + + File's Owner + + + 4 + + + App Delegate + + + -2 + + + + + 27 + + + YES + + + + + + + + + + + + + + + + + + + + + + Clock view + + + 48 + + + + + 107 + + + YES + + + + + + + + 108 + + + + + 109 + + + YES + + + + + + 110 + + + YES + + + + + + + + 111 + + + + + 112 + + + YES + + + + + + 113 + + + + + 114 + + + YES + + + + + + 115 + + + + + 116 + + + + + 122 + + + + + 123 + + + + + 124 + + + + + 125 + + + + + 126 + + + + + 127 + + + + + 128 + + + + + 129 + + + + + 130 + + + + + 131 + + + + + 132 + + + + + 133 + + + + + 134 + + + + + 135 + + + + + 136 + + + + + 137 + + + + + 138 + + + + + 139 + + + + + 121 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 107.IBEditorWindowLastContentRect + 107.IBPluginDependency + 108.IBPluginDependency + 109.CustomClassName + 112.CustomClassName + 115.IBPluginDependency + 116.IBPluginDependency + 122.CustomClassName + 122.IBPluginDependency + 123.CustomClassName + 123.IBPluginDependency + 124.CustomClassName + 124.IBPluginDependency + 125.CustomClassName + 125.IBPluginDependency + 126.CustomClassName + 126.IBPluginDependency + 127.CustomClassName + 127.IBPluginDependency + 128.CustomClassName + 128.IBPluginDependency + 129.CustomClassName + 129.IBPluginDependency + 130.CustomClassName + 130.IBPluginDependency + 131.CustomClassName + 131.IBPluginDependency + 132.CustomClassName + 132.IBPluginDependency + 133.CustomClassName + 133.IBPluginDependency + 134.CustomClassName + 134.IBPluginDependency + 135.CustomClassName + 135.IBPluginDependency + 136.CustomClassName + 136.IBPluginDependency + 137.CustomClassName + 137.IBPluginDependency + 139.IBPluginDependency + 2.IBAttributePlaceholdersKey + 2.IBEditorWindowLastContentRect + 2.IBPluginDependency + 2.UIWindow.visibleAtLaunch + 27.CustomClassName + 27.IBEditorWindowLastContentRect + 27.IBPluginDependency + 4.CustomClassName + 4.IBPluginDependency + 48.CustomClassName + 48.IBPluginDependency + + + YES + UIApplication + UIResponder + {{541, 221}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + SleepTimerSettingsViewController + AlarmSettingsViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ShadowedLabel + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + YES + + + YES + + + {{341, 276}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + ClockView + {{317, 436}, {480, 320}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + Sleep_Blaster_touchAppDelegate + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + ClockViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 159 + + + + YES + + AlarmSettingsViewController + UIViewController + + YES + + YES + buttonSegmentTapped: + chooseMusic: + clearDigits: + enterDigit: + pushMapView: + pushVoiceControls: + setAlarmDateInDatePicker: + toggleDatePicker: + toggleKeypad: + + + YES + UIButton + id + id + id + id + id + id + id + id + + + + YES + + YES + buttonSegmentTapped: + chooseMusic: + clearDigits: + enterDigit: + pushMapView: + pushVoiceControls: + setAlarmDateInDatePicker: + toggleDatePicker: + toggleKeypad: + + + YES + + buttonSegmentTapped: + UIButton + + + chooseMusic: + id + + + clearDigits: + id + + + enterDigit: + id + + + pushMapView: + id + + + pushVoiceControls: + id + + + setAlarmDateInDatePicker: + id + + + toggleDatePicker: + id + + + toggleKeypad: + id + + + + + YES + + YES + alarmDatePicker + alarmDatePickerContainerView + amountOfTimeLabel + navigationBar + tableView + + + YES + UIDatePicker + UIView + UILabel + UINavigationBar + UITableView + + + + YES + + YES + alarmDatePicker + alarmDatePickerContainerView + amountOfTimeLabel + navigationBar + tableView + + + YES + + alarmDatePicker + UIDatePicker + + + alarmDatePickerContainerView + UIView + + + amountOfTimeLabel + UILabel + + + navigationBar + UINavigationBar + + + tableView + UITableView + + + + + IBProjectSource + Classes/AlarmSettingsViewController.h + + + + ClockView + UIView + + IBProjectSource + ClockView.h + + + + ClockViewController + UIViewController + + YES + + YES + infoButtonTapped: + sleepTimerButtonTapped: + + + YES + id + id + + + + YES + + YES + infoButtonTapped: + sleepTimerButtonTapped: + + + YES + + infoButtonTapped: + id + + + sleepTimerButtonTapped: + id + + + + + YES + + YES + alarmBell + amLabel + backgroundImageView + colonLabel + friLabel + hourLabel1 + hourLabel2 + landscapeClockBackgroundView + minuteLabel1 + minuteLabel2 + monLabel + pmLabel + portraitAlarmBell + portraitAmLabel + portraitClockBackgroundView + portraitColonLabel + portraitFriLabel + portraitHourLabel1 + portraitHourLabel2 + portraitMinuteLabel1 + portraitMinuteLabel2 + portraitMonLabel + portraitPmLabel + portraitSatLabel + portraitSecondLabel1 + portraitSecondLabel2 + portraitSunLabel + portraitThuLabel + portraitTueLabel + portraitWedLabel + rightSettingsButton + satLabel + secondLabel1 + secondLabel2 + sunLabel + thuLabel + tueLabel + wedLabel + window + + + YES + UIImageView + ShadowedLabel + UIImageView + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + UIView + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + UIImageView + ShadowedLabel + UIView + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + UIButton + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + ShadowedLabel + UIWindow + + + + YES + + YES + alarmBell + amLabel + backgroundImageView + colonLabel + friLabel + hourLabel1 + hourLabel2 + landscapeClockBackgroundView + minuteLabel1 + minuteLabel2 + monLabel + pmLabel + portraitAlarmBell + portraitAmLabel + portraitClockBackgroundView + portraitColonLabel + portraitFriLabel + portraitHourLabel1 + portraitHourLabel2 + portraitMinuteLabel1 + portraitMinuteLabel2 + portraitMonLabel + portraitPmLabel + portraitSatLabel + portraitSecondLabel1 + portraitSecondLabel2 + portraitSunLabel + portraitThuLabel + portraitTueLabel + portraitWedLabel + rightSettingsButton + satLabel + secondLabel1 + secondLabel2 + sunLabel + thuLabel + tueLabel + wedLabel + window + + + YES + + alarmBell + UIImageView + + + amLabel + ShadowedLabel + + + backgroundImageView + UIImageView + + + colonLabel + ShadowedLabel + + + friLabel + ShadowedLabel + + + hourLabel1 + ShadowedLabel + + + hourLabel2 + ShadowedLabel + + + landscapeClockBackgroundView + UIView + + + minuteLabel1 + ShadowedLabel + + + minuteLabel2 + ShadowedLabel + + + monLabel + ShadowedLabel + + + pmLabel + ShadowedLabel + + + portraitAlarmBell + UIImageView + + + portraitAmLabel + ShadowedLabel + + + portraitClockBackgroundView + UIView + + + portraitColonLabel + ShadowedLabel + + + portraitFriLabel + ShadowedLabel + + + portraitHourLabel1 + ShadowedLabel + + + portraitHourLabel2 + ShadowedLabel + + + portraitMinuteLabel1 + ShadowedLabel + + + portraitMinuteLabel2 + ShadowedLabel + + + portraitMonLabel + ShadowedLabel + + + portraitPmLabel + ShadowedLabel + + + portraitSatLabel + ShadowedLabel + + + portraitSecondLabel1 + ShadowedLabel + + + portraitSecondLabel2 + ShadowedLabel + + + portraitSunLabel + ShadowedLabel + + + portraitThuLabel + ShadowedLabel + + + portraitTueLabel + ShadowedLabel + + + portraitWedLabel + ShadowedLabel + + + rightSettingsButton + UIButton + + + satLabel + ShadowedLabel + + + secondLabel1 + ShadowedLabel + + + secondLabel2 + ShadowedLabel + + + sunLabel + ShadowedLabel + + + thuLabel + ShadowedLabel + + + tueLabel + ShadowedLabel + + + wedLabel + ShadowedLabel + + + window + UIWindow + + + + + IBProjectSource + ClockViewController.h + + + + ShadowedLabel + UILabel + + IBProjectSource + Classes/ShadowedLabel.h + + + + SleepTimerSettingsViewController + UIViewController + + YES + + YES + buttonSegmentTapped: + chooseMusic: + doneButtonTapped: + nextSong: + previousSong: + setSleepTimerTime: + toggleDatePicker: + toggleSleepTimer: + volumeSliderMoved: + + + YES + UIButton + id + id + id + id + id + id + id + UISlider + + + + YES + + YES + buttonSegmentTapped: + chooseMusic: + doneButtonTapped: + nextSong: + previousSong: + setSleepTimerTime: + toggleDatePicker: + toggleSleepTimer: + volumeSliderMoved: + + + YES + + buttonSegmentTapped: + UIButton + + + chooseMusic: + id + + + doneButtonTapped: + id + + + nextSong: + id + + + previousSong: + id + + + setSleepTimerTime: + id + + + toggleDatePicker: + id + + + toggleSleepTimer: + id + + + volumeSliderMoved: + UISlider + + + + + YES + + YES + artistLabel + artworkContainerView + artworkImageView + button + datePicker + datePickerContainerView + musicTableView + navigationBar + nextButton + previousButton + segmentedControl + songLabel + timerLabel + timerTableView + volumeSlider + + + YES + UILabel + UIView + UIImageView + UIButton + UIDatePicker + UIView + UITableView + UINavigationBar + UIButton + UIButton + UISegmentedControl + UILabel + UILabel + UITableView + UISlider + + + + YES + + YES + artistLabel + artworkContainerView + artworkImageView + button + datePicker + datePickerContainerView + musicTableView + navigationBar + nextButton + previousButton + segmentedControl + songLabel + timerLabel + timerTableView + volumeSlider + + + YES + + artistLabel + UILabel + + + artworkContainerView + UIView + + + artworkImageView + UIImageView + + + button + UIButton + + + datePicker + UIDatePicker + + + datePickerContainerView + UIView + + + musicTableView + UITableView + + + navigationBar + UINavigationBar + + + nextButton + UIButton + + + previousButton + UIButton + + + segmentedControl + UISegmentedControl + + + songLabel + UILabel + + + timerLabel + UILabel + + + timerTableView + UITableView + + + volumeSlider + UISlider + + + + + IBProjectSource + SleepTimerSettingsViewController.h + + + + Sleep_Blaster_touchAppDelegate + NSObject + + YES + + YES + flipToClockView: + loadSongsAsynchronously: + + + YES + id + id + + + + YES + + YES + flipToClockView: + loadSongsAsynchronously: + + + YES + + flipToClockView: + id + + + loadSongsAsynchronously: + id + + + + + YES + + YES + clockViewController + tabBarController + window + + + YES + ClockViewController + UITabBarController + UIWindow + + + + YES + + YES + clockViewController + tabBarController + window + + + YES + + clockViewController + ClockViewController + + + tabBarController + UITabBarController + + + window + UIWindow + + + + + IBProjectSource + Classes/Sleep_Blaster_touchAppDelegate.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIApplication + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIApplication.h + + + + UIBarButtonItem + UIBarItem + + IBFrameworkSource + UIKit.framework/Headers/UIBarButtonItem.h + + + + UIBarItem + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIBarItem.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIDatePicker + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIDatePicker.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UINavigationBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UINavigationBar.h + + + + UINavigationController + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UINavigationItem + NSObject + + + + UIResponder + NSObject + + + + UIScrollView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIScrollView.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UISegmentedControl + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISegmentedControl.h + + + + UISlider + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISlider.h + + + + UITabBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITabBar.h + + + + UITabBarController + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UITabBarItem + UIBarItem + + IBFrameworkSource + UIKit.framework/Headers/UITabBarItem.h + + + + UITableView + UIScrollView + + IBFrameworkSource + UIKit.framework/Headers/UITableView.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + MediaPlayer.framework/Headers/MPMoviePlayerViewController.h + + + + UIViewController + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + UIWindow + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIWindow.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + YES + + YES + ClockView.png + bell.png + clockIcon.png + hourGlassIcon.png + info.png + + + YES + {480, 320} + {30, 30} + {30, 30} + {30, 30} + {20, 20} + + + 123 + + diff --git a/MapAnnotationView.h b/MapAnnotationView.h new file mode 100644 index 0000000..03a2570 --- /dev/null +++ b/MapAnnotationView.h @@ -0,0 +1,24 @@ +// +// MapAnnotationView.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 4/10/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import +#import + +@class MapAnnotationViewInternal; + +@interface MapAnnotationView : MKAnnotationView { + MKMapView *mapView; + MapAnnotationViewInternal* _internalAnnotationView; + +} + +- (void)regionChanged; + +@property (nonatomic, retain) MKMapView *mapView; + +@end diff --git a/MapAnnotationView.m b/MapAnnotationView.m new file mode 100644 index 0000000..ab2a5e4 --- /dev/null +++ b/MapAnnotationView.m @@ -0,0 +1,153 @@ +// +// MapAnnotationView.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 4/10/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "MapAnnotationView.h" +#import "MapLinesAnnotation.h" + +// this is an internally used view to CSRouteView. The CSRouteView needs a subview that does not get clipped to always +// be positioned at the full frame size and origin of the map. This way the view can be smaller than the route, but it +// always draws in the internal subview, which is the size of the map view. +@interface MapAnnotationViewInternal : UIView +{ + // route view which added this as a subview. + MapAnnotationView* _annotationView; +} +@property (nonatomic, retain) MapAnnotationView *annotationView; + +@end + + +@implementation MapAnnotationViewInternal + +@synthesize annotationView = _annotationView; + +-(id) init +{ + self = [super init]; + self.backgroundColor = [UIColor clearColor]; + self.clipsToBounds = NO; + + return self; +} + + +-(void) drawRect:(CGRect) rect +{ + // only draw our lines if we're not in the middle of a transition and we + // acutally have some points to draw. + MapLinesAnnotation *annotation = (MapLinesAnnotation *)self.annotationView.annotation; + if(!self.hidden && annotation.points && annotation.points.count > 0) + { + CGContextRef context = UIGraphicsGetCurrentContext(); + + // if(nil == routeAnnotation.lineColor) + // routeAnnotation.lineColor = [UIColor blueColor]; // setting the property instead of the member variable will automatically reatin it. + + CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.6, 0.0, 0.2, 1.0); + CGFloat lengths[1] = {4.0}; + CGContextSetLineDash(UIGraphicsGetCurrentContext(), 0, lengths, 1); + CGContextSetLineJoin(UIGraphicsGetCurrentContext(), kCGLineJoinRound); + CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 4.0); + + for(int i = 0; i < [annotation.points count]; i++) + { + CLLocation* location = [annotation.points objectAtIndex:i]; + CGPoint point = [self.annotationView.mapView convertCoordinate:location.coordinate toPointToView:self]; +// point.y += 40; + + if(i == 0) + { + // move to the first point + CGContextMoveToPoint(context, point.x, point.y); + } else { + CGContextAddLineToPoint(context, point.x, point.y); + } + } + CGContextStrokePath(context); + } +} + +-(void) dealloc +{ + self.annotationView = nil; + + [super dealloc]; +} + +@end + + + + + + + +@implementation MapAnnotationView + +@synthesize mapView; + +- (id)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { + + self.backgroundColor = [UIColor clearColor]; + + // do not clip the bounds. We need the MapAnnotationViewInternal to be able to render the route, regardless of where the + // actual annotation view is displayed. + self.clipsToBounds = NO; + + // create the internal annotation view that does the rendering of the route. + _internalAnnotationView = [[MapAnnotationViewInternal alloc] init]; + _internalAnnotationView.annotationView = self; + + [self addSubview:_internalAnnotationView]; + } + return self; +} + + +- (id)initWithAnnotation:(id )annotation reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]; + + self.backgroundColor = [UIColor clearColor]; + self.opaque = NO; + self.clipsToBounds = NO; + +// CGRect rect = CGRectMake(annotation.coordinate.longitude-(annotation.span.longitude/2), CGFloat y, CGFloat width, CGFloat height) + self.frame = CGRectMake(0, 0, 320, 480); + + // create the internal annotation view that does the rendering of the route. + _internalAnnotationView = [[MapAnnotationViewInternal alloc] init]; + _internalAnnotationView.annotationView = self; + + [self addSubview:_internalAnnotationView]; + + + return self; +} + +- (void)regionChanged +{ + // move the internal route view. + CGPoint origin = CGPointMake(0, 0); + origin = [mapView convertPoint:origin toView:self]; + + _internalAnnotationView.frame = CGRectMake(origin.x, origin.y, mapView.frame.size.width, mapView.frame.size.height); + [_internalAnnotationView setNeedsDisplay]; +} + +-(void) setMapView:(MKMapView*)newMapView +{ + [mapView release]; + mapView = [newMapView retain]; + + [self regionChanged]; +} + + +@end diff --git a/MapDrawingView.h b/MapDrawingView.h new file mode 100644 index 0000000..816b2a2 --- /dev/null +++ b/MapDrawingView.h @@ -0,0 +1,28 @@ +// +// MapDrawingView.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 4/10/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import + +@interface MapDrawingView : UIView { + + CGPoint lastPoint; + + UIImageView *drawImage; + BOOL mouseSwiped; + int mouseMoved; + + NSMutableArray *locations; +// NSMutableArray *points; + id delegate; +} +@property (nonatomic, retain) NSMutableArray *locations; +@property (assign) id delegate; + +- (void)clearAndHideCanvas; + +@end diff --git a/MapDrawingView.m b/MapDrawingView.m new file mode 100644 index 0000000..f288de0 --- /dev/null +++ b/MapDrawingView.m @@ -0,0 +1,163 @@ +// +// MapDrawingView.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 4/10/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "MapDrawingView.h" +#import +#import +#import "MapLinesAnnotation.h" +#import "Constants.h" +#import "AlarmController.h" + +@implementation MapDrawingView + +@synthesize locations; +@synthesize delegate; + +- (id)initWithFrame:(CGRect)frame { + if ((self = [super initWithFrame:frame])) { + locations = [[NSMutableArray array] retain]; +// points = [[NSMutableArray array] retain]; + + drawImage = [[UIImageView alloc] initWithImage:nil]; + drawImage.frame = frame; + [self addSubview:drawImage]; + self.opaque = NO; + self.backgroundColor = [UIColor clearColor]; + mouseMoved = 0; + } + return self; +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + NSLog(@"you touched it!"); + + [self.locations removeAllObjects]; +// [points removeAllObjects]; + + mouseSwiped = NO; + UITouch *touch = [touches anyObject]; + + if ([touch tapCount] == 2) { + drawImage.image = nil; + return; + } + + lastPoint = [touch locationInView:self]; +} + + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { + mouseSwiped = YES; + + UITouch *touch = [touches anyObject]; + CGPoint currentPoint = [touch locationInView:self]; + + MKMapView *mapView = self.superview; + + CLLocationCoordinate2D latAndLon = [mapView convertPoint:currentPoint toCoordinateFromView:mapView]; + + CLLocation *locationPoint = [[[CLLocation alloc] initWithLatitude:latAndLon.latitude longitude:latAndLon.longitude] autorelease]; + + [locations addObject:locationPoint]; +/* [points addObject:NSStringFromCGPoint(currentPoint)]; + CGPoint pointsArray[points.count]; + for (int i = 0; i < points.count; i++) + { + pointsArray[i] = CGPointFromString([points objectAtIndex:i]); + } +*/ + UIGraphicsBeginImageContext(self.frame.size); + [drawImage.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; + CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 4.0); + CGFloat lengths[1] = {4.0}; + CGContextSetLineDash(UIGraphicsGetCurrentContext(), 0, lengths, 1); + CGContextSetLineJoin(UIGraphicsGetCurrentContext(), kCGLineJoinRound); + CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.6, 0.0, 0.2, 1.0); + CGContextBeginPath(UIGraphicsGetCurrentContext()); + CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); + CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); + CGContextStrokePath(UIGraphicsGetCurrentContext()); + drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + lastPoint = currentPoint; + + mouseMoved++; + + if (mouseMoved == 10) { + mouseMoved = 0; + } + +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + + UITouch *touch = [touches anyObject]; + + if ([touch tapCount] == 2) { + drawImage.image = nil; + return; + } + + if(!mouseSwiped) { + UIGraphicsBeginImageContext(self.frame.size); + [drawImage.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; + CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 4.0); + CGFloat lengths[1] = {4.0}; + CGContextSetLineDash(UIGraphicsGetCurrentContext(), 0, lengths, 1); + CGContextSetLineJoin(UIGraphicsGetCurrentContext(), kCGLineJoinRound); + CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.6, 0.0, 0.2, 1.0); + CGContextBeginPath(UIGraphicsGetCurrentContext()); + CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); + CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); + CGContextStrokePath(UIGraphicsGetCurrentContext()); + drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + } + + MapLinesAnnotation *annotation = [[[MapLinesAnnotation alloc] initWithPoints:locations] autorelease]; + + MKMapView *mapView = self.superview; + [mapView addAnnotation:annotation]; + [delegate saveLocationPointsArrayToUserDefaults:locations]; + + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kAlarmOn]; + [[AlarmController sharedAlarmController] setupAlarm:self]; + + [self clearAndHideCanvas]; +} + +- (void)clearAndHideCanvas +{ + drawImage.image = nil; + self.hidden = YES; + + [[delegate drawButton] setBackgroundImage:[UIImage imageNamed:@"redDrawButton.png"] forState:UIControlStateNormal]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + + +- (void)dealloc { + [super dealloc]; +} + +/* +// Only override drawRect: if you perform custom drawing. +// An empty implementation adversely affects performance during animation. +- (void)drawRect:(CGRect)rect { + // Drawing code +} +*/ + + + +@end diff --git a/MapDrawingViewController.h b/MapDrawingViewController.h new file mode 100644 index 0000000..4998aaf --- /dev/null +++ b/MapDrawingViewController.h @@ -0,0 +1,27 @@ +// +// MapDrawingViewController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 5/4/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import + + +@interface MapDrawingViewController : UIViewController { + + CGPoint lastPoint; + UIImageView *drawImage; + BOOL mouseSwiped; + NSMutableArray *locations; + id delegate; +} + +@property (nonatomic, retain) NSMutableArray *locations; +@property (assign) id delegate; + +- (void)clearAndHideCanvas; + + +@end diff --git a/MapDrawingViewController.m b/MapDrawingViewController.m new file mode 100644 index 0000000..89a8192 --- /dev/null +++ b/MapDrawingViewController.m @@ -0,0 +1,171 @@ + // +// MapDrawingViewController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 5/4/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "MapDrawingViewController.h" +#import +#import +#import "MapLinesAnnotation.h" +#import "Constants.h" +#import "AlarmController.h" + + +@implementation MapDrawingViewController + + +@synthesize locations; +@synthesize delegate; + +/* + // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { + // Custom initialization + } + return self; +} +*/ + +/* +// Implement loadView to create a view hierarchy programmatically, without using a nib. +- (void)loadView { +} +*/ + +- (void)viewDidLoad { + [super viewDidLoad]; + + locations = [[NSMutableArray array] retain]; + + CGRect frame = CGRectMake(0, 44, 320, 480-(20+44+50)); + self.view.frame = frame; + self.view.opaque = NO; + self.view.backgroundColor = [UIColor clearColor]; + + drawImage = [[UIImageView alloc] initWithImage:nil]; + drawImage.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); + [self.view addSubview:drawImage]; +// mouseMoved = 0; +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + + [self.locations removeAllObjects]; + + mouseSwiped = NO; + UITouch *touch = [touches anyObject]; + + lastPoint = [touch locationInView:self.view]; +} + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { + mouseSwiped = YES; + + UITouch *touch = [touches anyObject]; + CGPoint currentPoint = [touch locationInView:self.view]; + +// MKMapView *mapView = self.view.superview; + + CLLocationCoordinate2D latAndLon = [[delegate mapView] convertPoint:currentPoint toCoordinateFromView:self.view]; + + CLLocation *locationPoint = [[[CLLocation alloc] initWithLatitude:latAndLon.latitude longitude:latAndLon.longitude] autorelease]; + + [locations addObject:locationPoint]; + + UIGraphicsBeginImageContext(self.view.frame.size); + [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; + CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 4.0); + CGFloat lengths[1] = {4.0}; + CGContextSetLineDash(UIGraphicsGetCurrentContext(), 0, lengths, 1); + CGContextSetLineJoin(UIGraphicsGetCurrentContext(), kCGLineJoinRound); + CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.6, 0.0, 0.2, 1.0); + CGContextBeginPath(UIGraphicsGetCurrentContext()); + CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); + CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); + CGContextStrokePath(UIGraphicsGetCurrentContext()); + drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + lastPoint = currentPoint; + +/* mouseMoved++; + + if (mouseMoved == 10) { + mouseMoved = 0; + } +*/} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + +// UITouch *touch = [touches anyObject]; + + if(!mouseSwiped) { + UIGraphicsBeginImageContext(self.view.frame.size); + [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; + CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 4.0); + CGFloat lengths[1] = {4.0}; + CGContextSetLineDash(UIGraphicsGetCurrentContext(), 0, lengths, 1); + CGContextSetLineJoin(UIGraphicsGetCurrentContext(), kCGLineJoinRound); + CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.6, 0.0, 0.2, 1.0); + CGContextBeginPath(UIGraphicsGetCurrentContext()); + CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); + CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); + CGContextStrokePath(UIGraphicsGetCurrentContext()); + drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + } + + MapLinesAnnotation *annotation = [[[MapLinesAnnotation alloc] initWithPoints:locations] autorelease]; + +// MKMapView *mapView = self.view.superview; + [[delegate mapView] addAnnotation:annotation]; + [delegate saveLocationPointsArrayToUserDefaults:locations]; + + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:1] forKey:kAlarmMode]; + + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kAlarmOn]; + [[AlarmController sharedAlarmController] setupAlarm:self]; + + [self clearAndHideCanvas]; +} + +- (void)clearAndHideCanvas +{ + drawImage.image = nil; + self.view.hidden = YES; + + [[delegate drawButton] setBackgroundImage:[UIImage imageNamed:@"redDrawButton.png"] forState:UIControlStateNormal]; +} + +/* +// Override to allow orientations other than the default portrait orientation. +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations + return (interfaceOrientation == UIInterfaceOrientationPortrait); +} +*/ + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + [super viewDidUnload]; + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/MapLinesAnnotation.h b/MapLinesAnnotation.h new file mode 100644 index 0000000..d6f03e7 --- /dev/null +++ b/MapLinesAnnotation.h @@ -0,0 +1,23 @@ +// +// MapLinesAnnotation.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 4/10/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import +#import + +@interface MapLinesAnnotation : NSObject { + NSMutableArray* points; + CLLocationCoordinate2D center; + MKCoordinateSpan span; +} + +- (id)initWithPoints:(NSArray *)thePoints; + +@property (nonatomic, retain) NSMutableArray* points; +@property (assign) MKCoordinateSpan span; + +@end diff --git a/MapLinesAnnotation.m b/MapLinesAnnotation.m new file mode 100644 index 0000000..067cb5f --- /dev/null +++ b/MapLinesAnnotation.m @@ -0,0 +1,58 @@ +// +// MapLinesAnnotation.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 4/10/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "MapLinesAnnotation.h" + + +@implementation MapLinesAnnotation + +@synthesize points; +@synthesize coordinate = center; +@synthesize span; + +- (id)initWithPoints:(NSArray *)thePoints +{ + self = [super init]; + + points = [thePoints mutableCopy]; + + // determine a logical center point for this route based on the middle of the lat/lon extents. + double maxLat = -91; + double minLat = 91; + double maxLon = -181; + double minLon = 181; + + for(CLLocation* currentLocation in points) + { + CLLocationCoordinate2D coordinate = currentLocation.coordinate; + + if(coordinate.latitude > maxLat) + maxLat = coordinate.latitude; + if(coordinate.latitude < minLat) + minLat = coordinate.latitude; + if(coordinate.longitude > maxLon) + maxLon = coordinate.longitude; + if(coordinate.longitude < minLon) + minLon = coordinate.longitude; + } + + span.latitudeDelta = (maxLat + 90) - (minLat + 90); + span.longitudeDelta = (maxLon + 180) - (minLon + 180); + + // the center point is the average of the max and mins + center.latitude = minLat + span.latitudeDelta / 2; + center.longitude = minLon + span.longitudeDelta / 2; + +// self.lineColor = [UIColor blueColor]; + NSLog(@"Found center of new Route Annotation at %lf, %lf", center.latitude, center.longitude); + + + return self; +} + +@end diff --git a/MapView-iPad.xib b/MapView-iPad.xib new file mode 100644 index 0000000..30f0269 --- /dev/null +++ b/MapView-iPad.xib @@ -0,0 +1,691 @@ + + + + 1024 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 123 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + 301 + + YES + + + 274 + {320, 480} + + YES + YES + IBIPadFramework + + + + 256 + {{0, 425}, {320, 50}} + + NO + YES + 4 + YES + IBIPadFramework + + NSImage + mapBottomBar.png + + + + + 292 + {{124, 429}, {72, 40}} + + NO + IBIPadFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + + 3 + MQA + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + NSImage + redDrawButton.png + + + + + 292 + {{20, 430}, {38, 38}} + + NO + IBIPadFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + NSImage + currentLocation.png + + + + + 292 + {{262, 430}, {38, 38}} + + NO + IBIPadFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + NSImage + findLine.png + + + + {320, 480} + + + 3 + MQA + + 2 + + + IBIPadFramework + + + + + YES + + + view + + + + 4 + + + + currentLocationButton + + + + 10 + + + + drawButton + + + + 11 + + + + centerOnCurrentLocation: + + + 7 + + 12 + + + + toggleDrawingView: + + + 7 + + 13 + + + + centerOnLine: + + + 7 + + 14 + + + + mapView + + + + 15 + + + + delegate + + + + 16 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 3 + + + YES + + + + + + + + + + 5 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + 17 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 17.IBViewBoundsToFrameTransform + 3.IBEditorWindowLastContentRect + 3.IBPluginDependency + 5.IBPluginDependency + 5.IBViewBoundsToFrameTransform + 7.IBPluginDependency + 7.IBViewBoundsToFrameTransform + 8.IBPluginDependency + 8.IBViewBoundsToFrameTransform + 9.IBPluginDependency + 9.IBViewBoundsToFrameTransform + + + YES + MapViewController + UIResponder + + P4AAAL+AAAAAAAAAw9mAAA + + {{312, 254}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAAAAAAAAw4sAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABC+AAAw8cAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABBoAAAw8aAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABDgwAAw8aAAA + + + + + YES + + + YES + + + + + YES + + + YES + + + + 17 + + + + YES + + MapViewController + UIViewController + + YES + + YES + centerOnCurrentLocation: + centerOnLine: + toggleDrawingView: + + + YES + id + id + id + + + + YES + + YES + centerOnCurrentLocation: + centerOnLine: + toggleDrawingView: + + + YES + + centerOnCurrentLocation: + id + + + centerOnLine: + id + + + toggleDrawingView: + id + + + + + YES + + YES + currentLocationButton + drawButton + mapView + + + YES + UIButton + UIButton + MKMapView + + + + YES + + YES + currentLocationButton + drawButton + mapView + + + YES + + currentLocationButton + UIButton + + + drawButton + UIButton + + + mapView + MKMapView + + + + + IBProjectSource + MapViewController.h + + + + + YES + + MKMapView + UIView + + IBFrameworkSource + MapKit.framework/Headers/MKMapView.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + MediaPlayer.framework/Headers/MPMoviePlayerViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBIPadFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + YES + + YES + currentLocation.png + findLine.png + mapBottomBar.png + redDrawButton.png + + + YES + {38, 38} + {38, 38} + {320, 50} + {72, 40} + + + 123 + + diff --git a/MapView.xib b/MapView.xib new file mode 100644 index 0000000..0d8d7b4 --- /dev/null +++ b/MapView.xib @@ -0,0 +1,671 @@ + + + + 784 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 123 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + + YES + + + 274 + {320, 460} + + YES + YES + IBCocoaTouchFramework + + + + 256 + {{0, 410}, {320, 50}} + + NO + YES + 0.89999997615814209 + 4 + YES + IBCocoaTouchFramework + + NSImage + mapBottomBar.png + + + + + 292 + {{124, 415}, {72, 40}} + + NO + IBCocoaTouchFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + + 3 + MQA + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + NSImage + redDrawButton.png + + + + + 292 + {{20, 416}, {38, 38}} + + NO + IBCocoaTouchFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + NSImage + currentLocation.png + + + + + 292 + {{262, 416}, {38, 38}} + + NO + IBCocoaTouchFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + NSImage + findLine.png + + + + {320, 460} + + + + IBCocoaTouchFramework + + + + + YES + + + view + + + + 3 + + + + delegate + + + + 5 + + + + mapView + + + + 6 + + + + toggleDrawingView: + + + 7 + + 15 + + + + drawButton + + + + 16 + + + + centerOnCurrentLocation: + + + 7 + + 20 + + + + currentLocationButton + + + + 21 + + + + centerOnLine: + + + 7 + + 24 + + + + + YES + + 0 + + + + + + 1 + + + YES + + + + + + + + + + -1 + + + File's Owner + + + -2 + + + + + 4 + + + + + 12 + + + + + 14 + + + + + 19 + + + + + 22 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 14.IBPluginDependency + 19.IBPluginDependency + 22.IBPluginDependency + 4.IBPluginDependency + + + YES + MapViewController + UIResponder + {{616, 276}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 24 + + + + YES + + MapViewController + UIViewController + + YES + + YES + centerOnCurrentLocation: + centerOnLine: + toggleDrawingView: + + + YES + id + id + id + + + + YES + + YES + centerOnCurrentLocation: + centerOnLine: + toggleDrawingView: + + + YES + + centerOnCurrentLocation: + id + + + centerOnLine: + id + + + toggleDrawingView: + id + + + + + YES + + YES + currentLocationButton + drawButton + mapView + + + YES + UIButton + UIButton + MKMapView + + + + YES + + YES + currentLocationButton + drawButton + mapView + + + YES + + currentLocationButton + UIButton + + + drawButton + UIButton + + + mapView + MKMapView + + + + + IBProjectSource + MapViewController.h + + + + + YES + + MKMapView + UIView + + IBFrameworkSource + MapKit.framework/Headers/MKMapView.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + MediaPlayer.framework/Headers/MPMoviePlayerViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + YES + + YES + currentLocation.png + findLine.png + mapBottomBar.png + redDrawButton.png + + + YES + {38, 38} + {38, 38} + {320, 50} + {72, 40} + + + 123 + + diff --git a/MapViewController.h b/MapViewController.h new file mode 100644 index 0000000..7968d43 --- /dev/null +++ b/MapViewController.h @@ -0,0 +1,43 @@ +// +// MapViewController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 4/10/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import +#import +#import +#import "MapDrawingViewController.h" + +@interface MapViewController : UIViewController { + + IBOutlet MKMapView *mapView; + IBOutlet UIButton *drawButton; + IBOutlet UIButton *currentLocationButton; + CLLocationManager *locationManager; + MapDrawingViewController *drawingViewController; + BOOL centeredMapOnCurrentLocation; + BOOL shouldFollowCurrentLocation; + BOOL withinCloseProximity; + BOOL usingSignificantChangesOnly; + NSTimer *userLocationTimer; +} + +- (IBAction)toggleDrawingView:(id)sender; +- (IBAction)centerOnCurrentLocation:(id)sender; +- (IBAction)centerOnLine:(id)sender; +- (void)saveLocationPointsArrayToUserDefaults:(NSArray *)array; +- (NSArray *)restoreLocationPointsArrayFromUserDefaults; +//- (void)monitorForLineRegion; + +- (void)startTrackingLocation; +- (void)stopTrackingLocation; + +@property (nonatomic, retain) MKMapView *mapView; +@property (nonatomic, retain) MapDrawingViewController *drawingViewController; +@property (nonatomic, retain) CLLocationManager *locationManager; +@property (nonatomic, retain) IBOutlet UIButton *drawButton; + +@end diff --git a/MapViewController.m b/MapViewController.m new file mode 100644 index 0000000..63c3243 --- /dev/null +++ b/MapViewController.m @@ -0,0 +1,536 @@ +// +// MapViewController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 4/10/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "MapViewController.h" +#import "MapAnnotationView.h" +#import "MapLinesAnnotation.h" +#import +#import "Constants.h" +#import "AlarmController.h" +#import "Sleep_Blaster_touchAppDelegate.h" + +@implementation MapViewController + +@synthesize mapView; +@synthesize locationManager; +@synthesize drawButton; +@synthesize drawingViewController; + +/* + // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { + // Custom initialization + } + return self; +} +*/ + +- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id )annotation +{ + if ([annotation class] == [MKUserLocation class]) + { + return nil; + } + + static NSString *AnnotationViewID = @"annotationViewID"; + + MapAnnotationView *annotationView = + (MapAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID]; + if (annotationView == nil) + { + annotationView = [[[MapAnnotationView alloc] initWithFrame:CGRectMake(0, 0, mapView.frame.size.width, mapView.frame.size.height)] autorelease]; + + annotationView.annotation = annotation; + annotationView.mapView = mapView; + } + + annotationView.annotation = annotation; + + return annotationView; +} + +- (void)saveLocationPointsArrayToUserDefaults:(NSArray *)arrayOfLocations +{ + NSMutableArray *arrayOfNumbers = [NSMutableArray array]; + for (int i = 0; i < arrayOfLocations.count; i++) + { + NSNumber *latitude = [NSNumber numberWithDouble:((CLLocation *)[arrayOfLocations objectAtIndex:i]).coordinate.latitude]; + NSNumber *longitude = [NSNumber numberWithDouble:((CLLocation *)[arrayOfLocations objectAtIndex:i]).coordinate.longitude]; + + [arrayOfNumbers addObject:latitude]; + [arrayOfNumbers addObject:longitude]; + } + + [[NSUserDefaults standardUserDefaults] setObject:arrayOfNumbers forKey:kLocationPoints]; +// NSLog(@"Saved: %@", [[[NSUserDefaults standardUserDefaults] objectForKey:kLocationPoints] description]); +// NSLog(@"saved %d numbers", arrayOfNumbers.count); +} + +- (NSArray *)restoreLocationPointsArrayFromUserDefaults +{ + NSArray *arrayOfNumbers = [[NSUserDefaults standardUserDefaults] objectForKey:kLocationPoints]; + NSMutableArray *arrayOfLocations = [NSMutableArray array]; + + for (int i = 0; i < arrayOfNumbers.count; i+=2) + { + CLLocation *location = [[CLLocation alloc] initWithLatitude:[[arrayOfNumbers objectAtIndex:i] doubleValue] + longitude:[[arrayOfNumbers objectAtIndex:i+1] doubleValue]]; + [arrayOfLocations addObject:location]; + [location release]; + } + + return arrayOfLocations; +} + +- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated +{ + float versionNumber = [[UIDevice currentDevice].systemVersion floatValue]; + + + //if (!((Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]).backgroundSupported) + if (versionNumber < 4 && UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) + { + if (!animated) { +// NSLog(@"not centered anymore"); + shouldFollowCurrentLocation = NO; + [userLocationTimer invalidate]; + [currentLocationButton setBackgroundImage:[UIImage imageNamed:@"currentLocation.png"] forState:UIControlStateNormal]; + } + } else { + if (!centeredMapOnCurrentLocation) { +// NSLog(@"not centered anymore"); + shouldFollowCurrentLocation = NO; + [userLocationTimer invalidate]; + [currentLocationButton setBackgroundImage:[UIImage imageNamed:@"currentLocation.png"] forState:UIControlStateNormal]; + } + } + + centeredMapOnCurrentLocation = NO; + +} + +- (void)mapView:(MKMapView *)theMapView regionDidChangeAnimated:(BOOL)animated +{ + // Tell each _map lines_ annotation view (although there's probably only one) that the region changed, so it knows to redraw itself. + for (int i = 0; i < theMapView.annotations.count; i++) + { + NSObject* annotation = [theMapView.annotations objectAtIndex:i]; + if ([annotation class] == [MapLinesAnnotation class]) + { + [[theMapView viewForAnnotation:annotation] regionChanged]; + } + } +} + +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad { + [super viewDidLoad]; + + self.locationManager = [[[CLLocationManager alloc] init] autorelease]; + [locationManager retain]; + self.locationManager.delegate = self; + + NSArray *locations = [self restoreLocationPointsArrayFromUserDefaults]; + if ([locations count] > 0) + { + MapLinesAnnotation *annotation = [[[MapLinesAnnotation alloc] initWithPoints:[locations mutableCopy]] autorelease]; + [mapView addAnnotation:annotation]; + } + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(willResignActive:) + name:UIApplicationWillResignActiveNotification + object:[NSUserDefaults standardUserDefaults]]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(didBecomeActive:) + name:UIApplicationDidBecomeActiveNotification + object:[NSUserDefaults standardUserDefaults]]; + shouldFollowCurrentLocation = NO; + centeredMapOnCurrentLocation = NO; + //withinCloseProximity = NO; + usingSignificantChangesOnly = NO; +} + +- (void)willResignActive:(NSNotification *)notification +{ +// if (!withinCloseProximity) { + self.mapView.showsUserLocation = NO; +// [locationManager stopUpdatingLocation]; +// } +} + +- (void)didBecomeActive:(NSNotification *)notification +{ +// [locationManager startUpdatingLocation]; + self.mapView.showsUserLocation = YES; +} + +- (void)startTrackingLocation +{ + usingSignificantChangesOnly = NO; + [self.locationManager startUpdatingLocation]; +} + +- (void)stopTrackingLocation +{ + [self.locationManager stopUpdatingLocation]; + + if ([CLLocationManager respondsToSelector:@selector(significantLocationChangeMonitoringAvailable)] && + [CLLocationManager significantLocationChangeMonitoringAvailable]) + { + [self.locationManager stopMonitoringSignificantLocationChanges]; + } + usingSignificantChangesOnly = NO; +} + +/*- (void)monitorForLineRegion +{ + NSLog(@"gonna try to monitor the region!"); + + if ([CLLocationManager regionMonitoringAvailable]) + { + CLLocationCoordinate2D coordinate; + MKCoordinateSpan span; + for (int i = 0; i < mapView.annotations.count; i++) + { + NSObject *annotation = [mapView.annotations objectAtIndex:i]; + if ([annotation class] == [MapLinesAnnotation class]) + { + coordinate = annotation.coordinate; + span = ((MapLinesAnnotation *)annotation).span; + } + } + + CLLocationDistance radius; + if (span.latitudeDelta > span.longitudeDelta) + { + radius = span.latitudeDelta/2 * 111000; + } else { + radius = span.longitudeDelta/2 * 111000; + } + + CLRegion *region = [CLRegion initCircularRegionWithCenter:coordinate radius:radius identifier:@"line"]; + [locationManager startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyNearestTenMeters]; + NSLog(@"just started monitoring for region!"); + } +} + + +- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region +{ + NSLog(@"did enter region!"); + [locationManager startUpdatingLocation]; +} +*/ + +- (void)viewWillAppear:(BOOL)animated +{ + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + CGSize size = {320, 540}; + self.contentSizeForViewInPopover = size; + } +} + +- (void)viewDidAppear:(BOOL)animated +{ +// NSLog(@"map view did appear!"); + if (locationManager.locationServicesEnabled/* && [CLLocationManager significantLocationChangeMonitoringAvailable]*/) + { + [locationManager startUpdatingLocation]; + self.mapView.showsUserLocation = YES; + } + + if (![[[NSUserDefaults standardUserDefaults] objectForKey:kHasShownDrawingMessage] boolValue]) + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Drawing on the map" message:@"Tap the red button to draw a line or a shape anywhere on the map that you would like to wake up. When you cross the line, the alarm will go off!" + delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; + [alert show]; + [alert release]; + + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kHasShownDrawingMessage]; + } +} + +- (void)viewDidDisappear:(BOOL)animated +{ + self.mapView.showsUserLocation = NO; + if (![[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue]) + { + //[locationManager stopUpdatingLocation]; + [self stopTrackingLocation]; + }/* else if (!withinCloseProximity) { + [locationManager stopUpdatingLocation]; + } +*/ +} + +- (IBAction)toggleDrawingView:(id)sender +{ + if (!self.drawingViewController) // by adding the drawing view we automatically show it + { + [drawButton setBackgroundImage:[UIImage imageNamed:@"redDrawButtonPressed.png"] forState:UIControlStateNormal]; + for (int i = 0; i < mapView.annotations.count; i++) + { + NSObject *annotation = [mapView.annotations objectAtIndex:i]; + if ([annotation class] == [MapLinesAnnotation class]) + { + [mapView removeAnnotation:annotation]; + } + } + self.drawingViewController = [[MapDrawingViewController alloc] init]; + self.drawingViewController.delegate = self; +// self.drawingViewController.view.frame = frame; +// self.drawingViewController.view.backgroundColor = [UIColor blueColor]; +// self.drawingViewController.view = [[UIView alloc] initWithFrame:mapView.frame]; +// [self.mapView addSubview:drawingViewController.view]; + [self.view addSubview:drawingViewController.view]; + + } else { + + if (self.drawingViewController.view.hidden) + { + self.drawingViewController.view.hidden = NO; + [drawButton setBackgroundImage:[UIImage imageNamed:@"redDrawButtonPressed.png"] forState:UIControlStateNormal]; + + for (int i = 0; i < mapView.annotations.count; i++) + { + NSObject *annotation = [mapView.annotations objectAtIndex:i]; + if ([annotation class] == [MapLinesAnnotation class]) + { + [mapView removeAnnotation:annotation]; + } + } + } else { + [drawingViewController clearAndHideCanvas]; + } + } +} + +- (IBAction)centerOnCurrentLocation:(id)sender +{ + if (sender == currentLocationButton && // if the user clicked the button when it's already on, turn it off. + shouldFollowCurrentLocation) + { + [currentLocationButton setBackgroundImage:[UIImage imageNamed:@"currentLocation.png"] forState:UIControlStateNormal]; + centeredMapOnCurrentLocation = NO; + shouldFollowCurrentLocation = NO; + [userLocationTimer invalidate]; + + } else { // otherwise, the user is turning it on. + [currentLocationButton setBackgroundImage:[UIImage imageNamed:@"currentLocationGlowing.png"] forState:UIControlStateNormal]; + centeredMapOnCurrentLocation = YES; + shouldFollowCurrentLocation = YES; + +// MKCoordinateSpan span = MKCoordinateSpanMake(.004, .004); +// MKCoordinateRegion region = MKCoordinateRegionMake(mapView.userLocation.location.coordinate, span); +// [mapView setRegion:region animated:YES]; + + userLocationTimer = [NSTimer scheduledTimerWithTimeInterval:.5 target:self selector:@selector(scheduledCenterOnCurrentLocation:) userInfo:nil repeats:YES]; + [userLocationTimer retain]; + + // [mapView setCenterCoordinate:mapView.userLocation.location.coordinate animated:YES]; + } +} + +- (void)scheduledCenterOnCurrentLocation:(NSTimer *)timer +{ +// NSLog(@"scheduled center"); + if (!self.mapView.showsUserLocation) + { + centeredMapOnCurrentLocation = NO; + shouldFollowCurrentLocation = NO; + [userLocationTimer invalidate]; + + return; + } + + if (shouldFollowCurrentLocation) + { +// NSLog(@"should follow"); + centeredMapOnCurrentLocation = YES; + + MKCoordinateSpan span = MKCoordinateSpanMake(.004, .004); + MKCoordinateRegion region = MKCoordinateRegionMake(mapView.userLocation.location.coordinate, span); + [mapView setRegion:region animated:YES]; + + } +} + +- (IBAction)centerOnLine:(id)sender +{ + CLLocationCoordinate2D coordinate; + MKCoordinateSpan span; + for (int i = 0; i < mapView.annotations.count; i++) + { + NSObject *annotation = [mapView.annotations objectAtIndex:i]; + if ([annotation class] == [MapLinesAnnotation class]) + { + coordinate = annotation.coordinate; + span = ((MapLinesAnnotation *)annotation).span; + } + } + + if (span.latitudeDelta && span.longitudeDelta) { + MKCoordinateRegion region = MKCoordinateRegionMake(coordinate, span); + [mapView setRegion:region animated:YES]; + } +} + +#define PI 3.141592653589793238462643 + +- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation +{ + NSLog(@"updated location"); + + if (![[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmOn] boolValue] || + [[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmMode] intValue] != 1 || + !mapView.annotations.count) + { + return; + } + + // loop through each annotation.... + for (int i = 0; i < mapView.annotations.count; i++) + { + NSObject* annotation = [mapView.annotations objectAtIndex:i]; + // ...and then check to make sure it's a MapLinesAnnotation. + if ([annotation class] == [MapLinesAnnotation class]) + { + if (((MapLinesAnnotation *)annotation).points.count) + { + BOOL notInProximityOfAnything = YES; + + for (int i = 0; i < ((MapLinesAnnotation *)annotation).points.count-1; i++) + { + CLLocation *location1 = [((MapLinesAnnotation *)annotation).points objectAtIndex:i]; + CLLocation *location2 = [((MapLinesAnnotation *)annotation).points objectAtIndex:i+1]; + + // Create an arbitrary point somewhere above point1. + // We'll use this point to convert the geographical distance of the error bound into pixel distance. + CLLocationCoordinate2D errorBoundLocation = location1.coordinate; + CLLocationCoordinate2D proximityLocation = location1.coordinate; + + errorBoundLocation.latitude += .00090; // add .00090 degree to the latitude, or about 100 meters. + proximityLocation.latitude += .07; // add .07 degree to the latitude, or about 8 kilometers. + + // Convert the geogrpahical points to pixel coordinates, because the distance between longitudes varies depending on where you are on the earth. + CGPoint point1 = [mapView convertCoordinate:location1.coordinate toPointToView:mapView]; + CGPoint point2 = [mapView convertCoordinate:location2.coordinate toPointToView:mapView]; + CGPoint errorBoundPoint = [mapView convertCoordinate:errorBoundLocation toPointToView:mapView]; + CGPoint proximityPoint = [mapView convertCoordinate:proximityLocation toPointToView:mapView]; + CGPoint currentLocation = [mapView convertCoordinate:newLocation.coordinate toPointToView:mapView]; + +// MKMapPoint point1 = MKMapPointForCoordinate(location1.coordinate); +// MKMapPoint point2 = MKMapPointForCoordinate(location2.coordinate); +// MKMapPoint errorBoundPoint = MKMapPointForCoordinate(errorBoundLocation); +// MKMapPoint currentLocation = MKMapPointForCoordinate(newLocation.coordinate); + + double x = currentLocation.x; +// double y = currentLocation.y; + + // Now convert everything to a cartesian coordinate system, with the origin being in the bottom left corner. + double y = mapView.frame.size.height-currentLocation.y; + point1.y = mapView.frame.size.height-point1.y; + point2.y = (mapView.frame.size.height-point2.y); + double errorBound = (mapView.frame.size.height-errorBoundPoint.y) - point1.y; + double proximity = (mapView.frame.size.height-proximityPoint.y) - point1.y; + + // Define some math variables. We'll really only use x, y, m, b, and db in the final equation though. + double dy = point2.y-point1.y; + double dx = point2.x-point1.x; + if (dx == 0) + dx = .0000000000001; // don't let dx equal zero, but instead set it to some number that's very close to zero. + double m = dy/dx; + double b = (point1.y-m*point1.x); + double angle = (PI/2)-atan(m); + double db = errorBound/sin(angle); + double proximityDB = proximity/sin(angle); + + if (((point1.x - proximity) < x && x < (point2.x + proximity)) || ((point2.x - proximity) < x && x < (point1.x + proximity))) + { + if (fabs(m*x + b - y) < proximityDB) + { + // we're within proximity. + + if (((point1.x - errorBound) < x && x < (point2.x + errorBound)) || ((point2.x - errorBound) < x && x < (point1.x + errorBound))) + { + if (fabs(m*x + b - y) < db) + { + // we're on the line! + + + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:NO] forKey:kAlarmOn]; + [[AlarmController sharedAlarmController] setOffAlarm:nil]; + + break; + } + } + + notInProximityOfAnything = NO; + if ([CLLocationManager respondsToSelector:@selector(significantLocationChangeMonitoringAvailable)] && + [CLLocationManager significantLocationChangeMonitoringAvailable]) + { + // NSLog(@"it can use significant changes!"); + if (usingSignificantChangesOnly) + { + [locationManager stopMonitoringSignificantLocationChanges]; + [locationManager startUpdatingLocation]; + usingSignificantChangesOnly = NO; + //withinCloseProximity = YES; + } + } + } + } + } // end of the loop here + + if (notInProximityOfAnything) + { + //withinCloseProximity = NO; + if ([CLLocationManager respondsToSelector:@selector(significantLocationChangeMonitoringAvailable)] && + [CLLocationManager significantLocationChangeMonitoringAvailable]) + { +// NSLog(@"it can use significant changes!"); + if (!usingSignificantChangesOnly && !self.mapView.showsUserLocation) + { + // NSLog(@"switching to significant changes only..."); + [locationManager stopUpdatingLocation]; + [locationManager startMonitoringSignificantLocationChanges]; + usingSignificantChangesOnly = YES; + } + } + } + } + } + } +} + +#define degreesToRadian(x) (M_PI * x / 180.0) + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. +// [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + + [super viewDidUnload]; + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/MeterTable.cpp b/MeterTable.cpp new file mode 100644 index 0000000..50b828e --- /dev/null +++ b/MeterTable.cpp @@ -0,0 +1,86 @@ +/* + + File: MeterTable.cpp +Abstract: Class for handling conversion from linear scale to dB + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#include "MeterTable.h" + +inline double DbToAmp(double inDb) +{ + return pow(10., 0.05 * inDb); +} + +MeterTable::MeterTable(float inMinDecibels, size_t inTableSize, float inRoot) + : mMinDecibels(inMinDecibels), + mDecibelResolution(mMinDecibels / (inTableSize - 1)), + mScaleFactor(1. / mDecibelResolution) +{ + if (inMinDecibels >= 0.) + { + printf("MeterTable inMinDecibels must be negative"); + return; + } + + mTable = (float*)malloc(inTableSize*sizeof(float)); + + double minAmp = DbToAmp(inMinDecibels); + double ampRange = 1. - minAmp; + double invAmpRange = 1. / ampRange; + + double rroot = 1. / inRoot; + for (size_t i = 0; i < inTableSize; ++i) { + double decibels = i * mDecibelResolution; + double amp = DbToAmp(decibels); + double adjAmp = (amp - minAmp) * invAmpRange; + mTable[i] = pow(adjAmp, rroot); + } +} + +MeterTable::~MeterTable() +{ + free(mTable); +} diff --git a/MeterTable.h b/MeterTable.h new file mode 100644 index 0000000..6cb368c --- /dev/null +++ b/MeterTable.h @@ -0,0 +1,79 @@ +/* + + File: MeterTable.h +Abstract: Class for handling conversion from linear scale to dB + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#include +#include +#include + +class MeterTable +{ +public: +// MeterTable constructor arguments: +// inNumUISteps - the number of steps in the UI element that will be drawn. +// This could be a height in pixels or number of bars in an LED style display. +// inTableSize - The size of the table. The table needs to be large enough that there are no large gaps in the response. +// inMinDecibels - the decibel value of the minimum displayed amplitude. +// inRoot - this controls the curvature of the response. 2.0 is square root, 3.0 is cube root. But inRoot doesn't have to be integer valued, it could be 1.8 or 2.5, etc. + +MeterTable(float inMinDecibels = -80., size_t inTableSize = 400, float inRoot = 2.0); +~MeterTable(); + + float ValueAt(float inDecibels) + { + if (inDecibels < mMinDecibels) return 0.; + if (inDecibels >= 0.) return 1.; + int index = (int)(inDecibels * mScaleFactor); + return mTable[index]; + } +private: + float mMinDecibels; + float mDecibelResolution; + float mScaleFactor; + float *mTable; +}; diff --git a/NSLocale+Misc.h b/NSLocale+Misc.h new file mode 100644 index 0000000..3aafff9 --- /dev/null +++ b/NSLocale+Misc.h @@ -0,0 +1,16 @@ +// +// NSLocale+Misc.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 7/14/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import + + +@interface NSLocale (Misc) + +- (BOOL)timeIs24HourFormat; + +@end diff --git a/NSLocale+Misc.m b/NSLocale+Misc.m new file mode 100644 index 0000000..2c472c8 --- /dev/null +++ b/NSLocale+Misc.m @@ -0,0 +1,26 @@ +// +// NSLocale+Misc.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 7/14/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "NSLocale+Misc.h" + + +@implementation NSLocale (Misc) + +- (BOOL)timeIs24HourFormat { + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + [formatter setDateStyle:NSDateFormatterNoStyle]; + [formatter setTimeStyle:NSDateFormatterShortStyle]; + NSString *dateString = [formatter stringFromDate:[NSDate date]]; + NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]]; + NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]]; + BOOL is24Hour = amRange.location == NSNotFound && pmRange.location == NSNotFound; + [formatter release]; + return is24Hour; +} + +@end diff --git a/NightView.h b/NightView.h new file mode 100644 index 0000000..76766a9 --- /dev/null +++ b/NightView.h @@ -0,0 +1,16 @@ +// +// NightView.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 10/7/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import + + +@interface NightView : UIView { + +} + +@end diff --git a/NightView.m b/NightView.m new file mode 100644 index 0000000..e67723a --- /dev/null +++ b/NightView.m @@ -0,0 +1,33 @@ +// +// NightView.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 10/7/09. +// Copyright 2009 The Byte Factory. All rights reserved. +// + +#import "NightView.h" + + +@implementation NightView + + +- (id)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { + } + return self; +} + +- (void)drawRect:(CGRect)rect { + CGContextRef context = UIGraphicsGetCurrentContext(); + CGContextSetRGBFillColor(context, 0.0,0.0,0.0,1.0); + CGContextFillRect(context, rect); +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/NoArtwork.tif b/NoArtwork.tif new file mode 100644 index 0000000..91dab21 Binary files /dev/null and b/NoArtwork.tif differ diff --git a/NoiseListener.h b/NoiseListener.h new file mode 100644 index 0000000..2f29bd9 --- /dev/null +++ b/NoiseListener.h @@ -0,0 +1,75 @@ +/* + + File: SpeakHereController.h +Abstract: Class for handling user interaction and file record/playback + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#import + +#import "AQRecorder.h" + + +@interface NoiseListener : NSObject { + + AQRecorder* recorder; + AudioQueueRef _aq; + NSArray *_channelNumbers; + AudioQueueLevelMeterState *_chan_lvls; + NSTimer *_updateTimer; + + id delegate; +} + +@property (readonly) AQRecorder *recorder; +@property id delegate; + + +- (IBAction)startListening:(id)sender; +- (IBAction)stopListening:(id)sender; + +- (void)setAq:(AudioQueueRef)v; + +@end diff --git a/NoiseListener.mm b/NoiseListener.mm new file mode 100644 index 0000000..c7c1b95 --- /dev/null +++ b/NoiseListener.mm @@ -0,0 +1,441 @@ +// +/* + + File: SpeakHereController.mm +Abstract: n/a + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#import "NoiseListener.h" + + +@implementation NoiseListener + +//@synthesize player; +@synthesize recorder; +@synthesize delegate; + +//@synthesize btn_record; +//@synthesize btn_play; +//@synthesize fileDescription; +//@synthesize lvlMeter_in; +//@synthesize playbackWasInterrupted; + +//char *OSTypeToStr(char *buf, OSType t) +//{ +// char *p = buf; +// char str[4], *q = str; +// *(UInt32 *)str = CFSwapInt32(t); +// for (int i = 0; i < 4; ++i) { +// if (isprint(*q) && *q != '\\') +// *p++ = *q++; +// else { +// sprintf(p, "\\x%02x", *q++); +// p += 4; +// } +// } +// *p = '\0'; +// return buf; +//} +// +//-(void)setFileDescriptionForFormat: (CAStreamBasicDescription)format withName:(NSString*)name +//{ +// char buf[5]; +// const char *dataFormat = OSTypeToStr(buf, format.mFormatID); +// NSString* description = [[NSString alloc] initWithFormat:@"(%d ch. %s @ %g Hz)", format.NumberChannels(), dataFormat, format.mSampleRate, nil]; +// fileDescription.text = description; +// [description release]; +//} + +#pragma mark Playback routines + +//-(void)stopPlayQueue +//{ +// player->StopQueue(); +// [lvlMeter_in setAq: nil]; +// btn_record.enabled = YES; +//} + +//- (void)stopRecord +//{ +// // Disconnect our level meter from the audio queue +// [lvlMeter_in setAq: nil]; +// +// recorder->StopRecord(); +// +// // dispose the previous playback queue +// player->DisposeQueue(true); +// +// // now create a new queue for the recorded file +// recordFilePath = (CFStringRef)[NSTemporaryDirectory() stringByAppendingPathComponent: @"recordedFile.caf"]; +// player->CreateQueueForFile(recordFilePath); +// +// // Set the button's state back to "record" +// btn_record.title = @"Record"; +// btn_play.enabled = YES; +//} + +//- (IBAction)play:(id)sender +//{ +// if (player->IsRunning()) +// [self stopPlayQueue]; +// +// else +// { +// OSStatus result = player->StartQueue(false); +// if (result == noErr) +// [[NSNotificationCenter defaultCenter] postNotificationName:@"playbackQueueResumed" object:self]; +// } +//} + +- (IBAction)startListening:(id)sender +{ + NSLog(@"about to start listening..."); +// if (recorder->IsRunning()) // If we are currently recording, stop and save the file. +// { +// } +// else // If we're not recording, start. +// { + // Start the recorder + recorder->StartRecord(CFSTR("recordedFile.caf")); + + // Hook the level meter up to the Audio Queue for the recorder + [self setAq: recorder->Queue()]; +// } +} + +- (IBAction)stopListening:(id)sender +{ + NSLog(@"about to stop listening..."); + if (_updateTimer) { + [_updateTimer invalidate]; + } +} + +- (void)setAq:(AudioQueueRef)v +{ +// if ((_aq == NULL) && (v != NULL)) +// { + if (_updateTimer) { + [_updateTimer invalidate]; + } + + _updateTimer = [[NSTimer + scheduledTimerWithTimeInterval:.1 + target:self + selector:@selector(_refresh) + userInfo:nil + repeats:YES] retain]; +// } + // } else if ((_aq != NULL) && (v == NULL)) { + // _peakFalloffLastFire = CFAbsoluteTimeGetCurrent(); + // } + + _aq = v; + + if (_aq) + { + try { + UInt32 val = 1; + XThrowIfError(AudioQueueSetProperty(_aq, kAudioQueueProperty_EnableLevelMetering, &val, sizeof(UInt32)), "couldn't enable metering"); + + // now check the number of channels in the new queue, we will need to reallocate if this has changed + CAStreamBasicDescription queueFormat; + UInt32 data_sz = sizeof(queueFormat); + XThrowIfError(AudioQueueGetProperty(_aq, kAudioQueueProperty_StreamDescription, &queueFormat, &data_sz), "couldn't get stream description"); + + if (queueFormat.NumberChannels() != [_channelNumbers count]) + { + NSArray *chan_array; + if (queueFormat.NumberChannels() < 2) + chan_array = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:0], nil]; + else + chan_array = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:0], [NSNumber numberWithInt:1], nil]; + + //[self setChannelNumbers:chan_array]; + [chan_array retain]; + [_channelNumbers release]; + _channelNumbers = chan_array; + + [chan_array release]; + + _chan_lvls = (AudioQueueLevelMeterState*)realloc(_chan_lvls, queueFormat.NumberChannels() * sizeof(AudioQueueLevelMeterState)); + } + } + catch (CAXException e) { + char buf[256]; + fprintf(stderr, "Error: %s (%s)\n", e.mOperation, e.FormatError(buf)); + } + } +} + +- (void)_refresh +{ + // BOOL success = NO; + + // if we have no queue, but still have levels, gradually bring them down + // if (_aq == NULL) + // { + // CGFloat maxLvl = -1.; + // CFAbsoluteTime thisFire = CFAbsoluteTimeGetCurrent(); + // // calculate how much time passed since the last draw + // CFAbsoluteTime timePassed = thisFire - _peakFalloffLastFire; + // for (LevelMeter *thisMeter in _subLevelMeters) + // { + // CGFloat newPeak, newLevel; + // newLevel = thisMeter.level - timePassed * kLevelFalloffPerSec; + // if (newLevel < 0.) newLevel = 0.; + // thisMeter.level = newLevel; + // if (_showsPeaks) + // { + // newPeak = thisMeter.peakLevel - timePassed * kPeakFalloffPerSec; + // if (newPeak < 0.) newPeak = 0.; + // thisMeter.peakLevel = newPeak; + // if (newPeak > maxLvl) maxLvl = newPeak; + // } + // else if (newLevel > maxLvl) maxLvl = newLevel; + // + // [thisMeter setNeedsDisplay]; + // } + // // stop the timer when the last level has hit 0 + // if (maxLvl <= 0.) + // { + // [_updateTimer invalidate]; + // _updateTimer = nil; + // } + // + // _peakFalloffLastFire = thisFire; + // success = YES; + // } else { + + UInt32 data_sz = sizeof(AudioQueueLevelMeterState) * [_channelNumbers count]; + OSErr status = AudioQueueGetProperty(_aq, kAudioQueueProperty_CurrentLevelMeter, _chan_lvls, &data_sz); + //if (status != noErr) goto bail; + + for (int i=0; i<[_channelNumbers count]; i++) + { + NSInteger channelIdx = [(NSNumber *)[_channelNumbers objectAtIndex:i] intValue]; + //LevelMeter *channelView = [_subLevelMeters objectAtIndex:channelIdx]; + + //if (channelIdx >= [_channelNumbers count]) goto bail; + //if (channelIdx > 127) goto bail; + + if (_chan_lvls) + { + // There seems to be a bug with passing a float to processVolumeReading:, but passing a double works fine. + double volumeLevel = (double)_chan_lvls[channelIdx].mAveragePower; + + //[delegate processVolumeReading:[NSNumber numberWithFloat:volumeLevel]]; + [NSThread detachNewThreadSelector:@selector(processVolumeReading:) toTarget:delegate withObject:[NSNumber numberWithFloat:volumeLevel]]; + + } + } + // } + + //bail: + // + // if (!success) + // { + // for (LevelMeter *thisMeter in _subLevelMeters) { thisMeter.level = 0.; [thisMeter setNeedsDisplay]; } + // printf("ERROR: metering failed\n"); + // } +} + +#pragma mark AudioSession listeners +void interruptionListener( void * inClientData, + UInt32 inInterruptionState) +{ +// SpeakHereController *THIS = (SpeakHereController*)inClientData; +// if (inInterruptionState == kAudioSessionBeginInterruption) +// { +// if (THIS->recorder->IsRunning()) { +// [THIS stopRecord]; +// } +// else if (THIS->player->IsRunning()) { +// //the queue will stop itself on an interruption, we just need to update the AI +// [[NSNotificationCenter defaultCenter] postNotificationName:@"playbackQueueStopped" object:THIS]; +// THIS->playbackWasInterrupted = YES; +// } +// } +// else if ((inInterruptionState == kAudioSessionEndInterruption) && THIS->playbackWasInterrupted) +// { +// printf("Resuming queue\n"); +// // we were playing back when we were interrupted, so reset and resume now +// THIS->player->StartQueue(true); +// [[NSNotificationCenter defaultCenter] postNotificationName:@"playbackQueueResumed" object:THIS]; +// THIS->playbackWasInterrupted = NO; +// } +} + +void propListener( void * inClientData, + AudioSessionPropertyID inID, + UInt32 inDataSize, + const void * inData) +{ +// SpeakHereController *THIS = (SpeakHereController*)inClientData; +// if (inID == kAudioSessionProperty_AudioRouteChange) +// { +// CFDictionaryRef routeDictionary = (CFDictionaryRef)inData; +// //CFShow(routeDictionary); +// CFNumberRef reason = (CFNumberRef)CFDictionaryGetValue(routeDictionary, CFSTR(kAudioSession_AudioRouteChangeKey_Reason)); +// SInt32 reasonVal; +// CFNumberGetValue(reason, kCFNumberSInt32Type, &reasonVal); +// if (reasonVal != kAudioSessionRouteChangeReason_CategoryChange) +// { +// /*CFStringRef oldRoute = (CFStringRef)CFDictionaryGetValue(routeDictionary, CFSTR(kAudioSession_AudioRouteChangeKey_OldRoute)); +// if (oldRoute) +// { +// printf("old route:\n"); +// CFShow(oldRoute); +// } +// else +// printf("ERROR GETTING OLD AUDIO ROUTE!\n"); +// +// CFStringRef newRoute; +// UInt32 size; size = sizeof(CFStringRef); +// OSStatus error = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &size, &newRoute); +// if (error) printf("ERROR GETTING NEW AUDIO ROUTE! %d\n", error); +// else +// { +// printf("new route:\n"); +// CFShow(newRoute); +// }*/ +// +// if (reasonVal == kAudioSessionRouteChangeReason_OldDeviceUnavailable) +// { +// if (THIS->player->IsRunning()) { +// [THIS stopPlayQueue]; +// } +// } +// +// // stop the queue if we had a non-policy route change +// if (THIS->recorder->IsRunning()) { +// [THIS stopRecord]; +// } +// } +// } +// else if (inID == kAudioSessionProperty_AudioInputAvailable) +// { +// if (inDataSize == sizeof(UInt32)) { +// UInt32 isAvailable = *(UInt32*)inData; +// // disable recording if input is not available +// THIS->btn_record.enabled = (isAvailable > 0) ? YES : NO; +// } +// } +} + +#pragma mark Initialization routines +- (void)awakeFromNib +{ + _channelNumbers = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:0], nil]; + _chan_lvls = (AudioQueueLevelMeterState*)malloc(sizeof(AudioQueueLevelMeterState) * [_channelNumbers count]); + + // Allocate our singleton instance for the recorder & player object + recorder = new AQRecorder(); +// player = new AQPlayer(); + + OSStatus error = AudioSessionInitialize(NULL, NULL, interruptionListener, self); + if (error) { + printf("ERROR INITIALIZING AUDIO SESSION! %d\n", error); + } else { + OSStatus error = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange, propListener, self); + if (error) printf("ERROR ADDING AUDIO SESSION PROP LISTENER! %d\n", error); + UInt32 inputAvailable = 0; + UInt32 size = sizeof(inputAvailable); + + // we do not want to allow recording if input is not available + error = AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &size, &inputAvailable); + if (error) printf("ERROR GETTING INPUT AVAILABILITY! %d\n", error); +// btn_record.enabled = (inputAvailable) ? YES : NO; + + // we also need to listen to see if input availability changes + error = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioInputAvailable, propListener, self); + if (error) printf("ERROR ADDING AUDIO SESSION PROP LISTENER! %d\n", error); + } + +// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackQueueStopped:) name:@"playbackQueueStopped" object:nil]; +// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackQueueResumed:) name:@"playbackQueueResumed" object:nil]; +// +// UIColor *bgColor = [[UIColor alloc] initWithRed:.39 green:.44 blue:.57 alpha:.5]; +// [lvlMeter_in setBackgroundColor:bgColor]; +// [lvlMeter_in setBorderColor:bgColor]; +// [bgColor release]; + + // disable the play button since we have no recording to play yet +// btn_play.enabled = NO; +// playbackWasInterrupted = NO; +} + +# pragma mark Notification routines +//- (void)playbackQueueStopped:(NSNotification *)note +//{ +// btn_play.title = @"Play"; +// [lvlMeter_in setAq: nil]; +// btn_record.enabled = YES; +//} +// +//- (void)playbackQueueResumed:(NSNotification *)note +//{ +// btn_play.title = @"Stop"; +// btn_record.enabled = NO; +// [lvlMeter_in setAq: player->Queue()]; +//} + +#pragma mark Cleanup +- (void)dealloc +{ +// [btn_record release]; +// [btn_play release]; +// [fileDescription release]; +// [lvlMeter_in release]; + +// delete player; + delete recorder; + + [super dealloc]; +} + + +@end diff --git a/Sleep Blaster touch.xcodeproj/eamonford.mode1v3 b/Sleep Blaster touch.xcodeproj/eamonford.mode1v3 new file mode 100644 index 0000000..203b45a --- /dev/null +++ b/Sleep Blaster touch.xcodeproj/eamonford.mode1v3 @@ -0,0 +1,1419 @@ + + + + + ActivePerspectiveName + Project + AllowedModules + + + BundleLoadPath + + MaxInstances + n + Module + PBXSmartGroupTreeModule + Name + Groups and Files Outline View + + + BundleLoadPath + + MaxInstances + n + Module + PBXNavigatorGroup + Name + Editor + + + BundleLoadPath + + MaxInstances + n + Module + XCTaskListModule + Name + Task List + + + BundleLoadPath + + MaxInstances + n + Module + XCDetailModule + Name + File and Smart Group Detail Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXBuildResultsModule + Name + Detailed Build Results Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXProjectFindModule + Name + Project Batch Find Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCProjectFormatConflictsModule + Name + Project Format Conflicts List + + + BundleLoadPath + + MaxInstances + n + Module + PBXBookmarksModule + Name + Bookmarks Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXClassBrowserModule + Name + Class Browser + + + BundleLoadPath + + MaxInstances + n + Module + PBXCVSModule + Name + Source Code Control Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXDebugBreakpointsModule + Name + Debug Breakpoints Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCDockableInspector + Name + Inspector + + + BundleLoadPath + + MaxInstances + n + Module + PBXOpenQuicklyModule + Name + Open Quickly Tool + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugSessionModule + Name + Debugger + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugCLIModule + Name + Debug Console + + + BundleLoadPath + + MaxInstances + n + Module + XCSnapshotModule + Name + Snapshots Tool + + + BundlePath + /Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources + Description + DefaultDescriptionKey + DockingSystemVisible + + Extension + mode1v3 + FavBarConfig + + PBXProjectModuleGUID + E127F64A0FDE410C00833255 + XCBarModuleItemNames + + XCBarModuleItems + + + FirstTimeWindowDisplayed + + Identifier + com.apple.perspectives.project.mode1v3 + MajorVersion + 33 + MinorVersion + 0 + Name + Default + Notifications + + OpenEditors + + PerspectiveWidths + + -1 + -1 + + Perspectives + + + ChosenToolbarItems + + active-combo-popup + action + NSToolbarFlexibleSpaceItem + debugger-enable-breakpoints + build-and-go + com.apple.ide.PBXToolbarStopButton + get-info + NSToolbarFlexibleSpaceItem + com.apple.pbx.toolbar.searchfield + + ControllerClassBaseName + + IconName + WindowOfProjectWithEditor + Identifier + perspective.project + IsVertical + + Layout + + + BecomeActive + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 299 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + E11B7A3811711F75008CFF9B + E1329DA41090A8B000787D98 + E11A31AC106C629200BE7E70 + E11A31AB106C628800BE7E70 + 29B97317FDCFA39411CA2CEA + 19C28FACFE9D520D11CA2CBB + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 37 + 36 + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 420}, {299, 510}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {316, 528}} + GroupTreeTableConfiguration + + MainColumn + 299 + + RubberWindowFrame + 206 209 753 569 0 0 1280 778 + + Module + PBXSmartGroupTreeModule + Proportion + 316pt + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20306471E060097A5F4 + PBXProjectModuleLabel + + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CE0B20406471E060097A5F4 + PBXProjectModuleLabel + + + SplitCount + 1 + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {432, 0}} + RubberWindowFrame + 206 209 753 569 0 0 1280 778 + + Module + PBXNavigatorGroup + Proportion + 0pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20506471E060097A5F4 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{0, 5}, {432, 523}} + RubberWindowFrame + 206 209 753 569 0 0 1280 778 + + Module + XCDetailModule + Proportion + 523pt + + + Proportion + 432pt + + + Name + Project + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + XCModuleDock + PBXNavigatorGroup + XCDetailModule + + TableOfContents + + E1D95FE8126FFB1E0028142E + 1CE0B1FE06471DED0097A5F4 + E1D95FE9126FFB1E0028142E + 1CE0B20306471E060097A5F4 + 1CE0B20506471E060097A5F4 + + ToolbarConfigUserDefaultsMinorVersion + 2 + ToolbarConfiguration + xcode.toolbar.config.defaultV3 + + + ControllerClassBaseName + + IconName + WindowOfProject + Identifier + perspective.morph + IsVertical + 0 + Layout + + + BecomeActive + 1 + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 11E0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 186 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {186, 337}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + 1 + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {203, 355}} + GroupTreeTableConfiguration + + MainColumn + 186 + + RubberWindowFrame + 373 269 690 397 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 100% + + + Name + Morph + PreferredWidth + 300 + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + + TableOfContents + + 11E0B1FE06471DED0097A5F4 + + ToolbarConfiguration + xcode.toolbar.config.default.shortV3 + + + PerspectivesBarVisible + + ShelfIsVisible + + SourceDescription + file at '/Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources/XCPerspectivesSpecificationMode1.xcperspec' + StatusbarIsVisible + + TimeStamp + 0.0 + ToolbarDisplayMode + 1 + ToolbarIsVisible + + ToolbarSizeMode + 1 + Type + Perspectives + UpdateMessage + The Default Workspace in this version of Xcode now includes support to hide and show the detail view (what has been referred to as the "Metro-Morph" feature). You must discard your current Default Workspace settings and update to the latest Default Workspace in order to gain this feature. Do you wish to update to the latest Workspace defaults for project '%@'? + WindowJustification + 5 + WindowOrderList + + 1C78EAAD065D492600B07095 + 1CD10A99069EF8BA00B06720 + E127F6510FDE43CB00833255 + /Users/eamonford/Desktop/Sleep Blaster touch/Sleep Blaster touch.xcodeproj + + WindowString + 206 209 753 569 0 0 1280 778 + WindowToolsV3 + + + FirstTimeWindowDisplayed + + Identifier + windowTool.build + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528F0623707200166675 + PBXProjectModuleLabel + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {1086, 372}} + RubberWindowFrame + 31 113 1086 665 0 0 1280 778 + + Module + PBXNavigatorGroup + Proportion + 372pt + + + ContentConfiguration + + PBXProjectModuleGUID + XCMainBuildResultsModuleGUID + PBXProjectModuleLabel + Build Results + XCBuildResultsTrigger_Collapse + 1021 + XCBuildResultsTrigger_Open + 1011 + + GeometryConfiguration + + Frame + {{0, 377}, {1086, 247}} + RubberWindowFrame + 31 113 1086 665 0 0 1280 778 + + Module + PBXBuildResultsModule + Proportion + 247pt + + + Proportion + 624pt + + + Name + Build Results + ServiceClasses + + PBXBuildResultsModule + + StatusbarIsVisible + + TableOfContents + + E127F6510FDE43CB00833255 + E1D95FEA126FFB1E0028142E + 1CD0528F0623707200166675 + XCMainBuildResultsModuleGUID + + ToolbarConfiguration + xcode.toolbar.config.buildV3 + WindowString + 31 113 1086 665 0 0 1280 778 + WindowToolGUID + E127F6510FDE43CB00833255 + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debugger + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + Debugger + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {815, 366}} + {{815, 0}, {369, 366}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {1184, 366}} + {{0, 366}, {1184, 311}} + + + + LauncherConfigVersion + 8 + PBXProjectModuleGUID + 1C162984064C10D400B95A72 + PBXProjectModuleLabel + Debug - GLUTExamples (Underwater) + + GeometryConfiguration + + DebugConsoleVisible + None + DebugConsoleWindowFrame + {{200, 200}, {500, 300}} + DebugSTDIOWindowFrame + {{200, 200}, {500, 300}} + Frame + {{0, 0}, {1184, 677}} + PBXDebugSessionStackFrameViewKey + + DebugVariablesTableConfiguration + + Name + 120 + Value + 85 + Summary + 139 + + Frame + {{815, 0}, {369, 366}} + RubberWindowFrame + 96 60 1184 718 0 0 1280 778 + + RubberWindowFrame + 96 60 1184 718 0 0 1280 778 + + Module + PBXDebugSessionModule + Proportion + 677pt + + + Proportion + 677pt + + + Name + Debugger + ServiceClasses + + PBXDebugSessionModule + + StatusbarIsVisible + + TableOfContents + + 1CD10A99069EF8BA00B06720 + E1D95FF3126FFC0F0028142E + 1C162984064C10D400B95A72 + E1D95FF4126FFC0F0028142E + E1D95FF5126FFC0F0028142E + E1D95FF6126FFC0F0028142E + E1D95FF7126FFC0F0028142E + E1D95FF8126FFC0F0028142E + + ToolbarConfiguration + xcode.toolbar.config.debugV3 + WindowString + 96 60 1184 718 0 0 1280 778 + WindowToolGUID + 1CD10A99069EF8BA00B06720 + WindowToolIsVisible + + + + Identifier + windowTool.find + Layout + + + Dock + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CDD528C0622207200134675 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CD0528D0623707200166675 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {781, 167}} + RubberWindowFrame + 62 385 781 470 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 781pt + + + Proportion + 50% + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528E0623707200166675 + PBXProjectModuleLabel + Project Find + + GeometryConfiguration + + Frame + {{8, 0}, {773, 254}} + RubberWindowFrame + 62 385 781 470 0 0 1440 878 + + Module + PBXProjectFindModule + Proportion + 50% + + + Proportion + 428pt + + + Name + Project Find + ServiceClasses + + PBXProjectFindModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C530D57069F1CE1000CFCEE + 1C530D58069F1CE1000CFCEE + 1C530D59069F1CE1000CFCEE + 1CDD528C0622207200134675 + 1C530D5A069F1CE1000CFCEE + 1CE0B1FE06471DED0097A5F4 + 1CD0528E0623707200166675 + + WindowString + 62 385 781 470 0 0 1440 878 + WindowToolGUID + 1C530D57069F1CE1000CFCEE + WindowToolIsVisible + 0 + + + Identifier + MENUSEPARATOR + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debuggerConsole + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAAC065D492600B07095 + PBXProjectModuleLabel + Debugger Console + + GeometryConfiguration + + Frame + {{0, 0}, {924, 421}} + RubberWindowFrame + 262 223 924 462 0 0 1280 778 + + Module + PBXDebugCLIModule + Proportion + 421pt + + + Proportion + 421pt + + + Name + Debugger Console + ServiceClasses + + PBXDebugCLIModule + + StatusbarIsVisible + + TableOfContents + + 1C78EAAD065D492600B07095 + E1D95FF9126FFC0F0028142E + 1C78EAAC065D492600B07095 + + ToolbarConfiguration + xcode.toolbar.config.consoleV3 + WindowString + 262 223 924 462 0 0 1280 778 + WindowToolGUID + 1C78EAAD065D492600B07095 + WindowToolIsVisible + + + + Identifier + windowTool.snapshots + Layout + + + Dock + + + Module + XCSnapshotModule + Proportion + 100% + + + Proportion + 100% + + + Name + Snapshots + ServiceClasses + + XCSnapshotModule + + StatusbarIsVisible + Yes + ToolbarConfiguration + xcode.toolbar.config.snapshots + WindowString + 315 824 300 550 0 0 1440 878 + WindowToolIsVisible + Yes + + + Identifier + windowTool.scm + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAB2065D492600B07095 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1C78EAB3065D492600B07095 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {452, 0}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + + Module + PBXNavigatorGroup + Proportion + 0pt + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD052920623707200166675 + PBXProjectModuleLabel + SCM + + GeometryConfiguration + + ConsoleFrame + {{0, 259}, {452, 0}} + Frame + {{0, 7}, {452, 259}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + TableConfiguration + + Status + 30 + FileName + 199 + Path + 197.0950012207031 + + TableFrame + {{0, 0}, {452, 250}} + + Module + PBXCVSModule + Proportion + 262pt + + + Proportion + 266pt + + + Name + SCM + ServiceClasses + + PBXCVSModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C78EAB4065D492600B07095 + 1C78EAB5065D492600B07095 + 1C78EAB2065D492600B07095 + 1CD052920623707200166675 + + ToolbarConfiguration + xcode.toolbar.config.scm + WindowString + 743 379 452 308 0 0 1280 1002 + + + Identifier + windowTool.breakpoints + IsVertical + 0 + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C77FABC04509CD000000102 + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + no + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 168 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 1C77FABC04509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {168, 350}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + 0 + + GeometryConfiguration + + Frame + {{0, 0}, {185, 368}} + GroupTreeTableConfiguration + + MainColumn + 168 + + RubberWindowFrame + 315 424 744 409 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 185pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CA1AED706398EBD00589147 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{190, 0}, {554, 368}} + RubberWindowFrame + 315 424 744 409 0 0 1440 878 + + Module + XCDetailModule + Proportion + 554pt + + + Proportion + 368pt + + + MajorVersion + 3 + MinorVersion + 0 + Name + Breakpoints + ServiceClasses + + PBXSmartGroupTreeModule + XCDetailModule + + StatusbarIsVisible + 1 + TableOfContents + + 1CDDB66807F98D9800BB5817 + 1CDDB66907F98D9800BB5817 + 1CE0B1FE06471DED0097A5F4 + 1CA1AED706398EBD00589147 + + ToolbarConfiguration + xcode.toolbar.config.breakpointsV3 + WindowString + 315 424 744 409 0 0 1440 878 + WindowToolGUID + 1CDDB66807F98D9800BB5817 + WindowToolIsVisible + 1 + + + Identifier + windowTool.debugAnimator + Layout + + + Dock + + + Module + PBXNavigatorGroup + Proportion + 100% + + + Proportion + 100% + + + Name + Debug Visualizer + ServiceClasses + + PBXNavigatorGroup + + StatusbarIsVisible + 1 + ToolbarConfiguration + xcode.toolbar.config.debugAnimatorV3 + WindowString + 100 100 700 500 0 0 1280 1002 + + + FirstTimeWindowDisplayed + + Identifier + windowTool.bookmarks + IsVertical + + Layout + + + Dock + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + E17B2A59115C65D300F31A78 + PBXProjectModuleLabel + Bookmarks + + GeometryConfiguration + + Frame + {{0, 0}, {401, 202}} + RubberWindowFrame + 179 491 401 222 0 0 1280 778 + + Module + PBXBookmarksModule + Proportion + 202pt + + + Proportion + 202pt + + + Name + Bookmarks + ServiceClasses + + PBXBookmarksModule + + StatusbarIsVisible + + TableOfContents + + E17B2A5A115C65D300F31A78 + E17B2A5B115C65D300F31A78 + E17B2A59115C65D300F31A78 + + WindowString + 179 491 401 222 0 0 1280 778 + WindowToolGUID + E17B2A5A115C65D300F31A78 + WindowToolIsVisible + + + + Identifier + windowTool.projectFormatConflicts + Layout + + + Dock + + + Module + XCProjectFormatConflictsModule + Proportion + 100% + + + Proportion + 100% + + + Name + Project Format Conflicts + ServiceClasses + + XCProjectFormatConflictsModule + + StatusbarIsVisible + 0 + WindowContentMinSize + 450 300 + WindowString + 50 850 472 307 0 0 1440 877 + + + Identifier + windowTool.classBrowser + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + OptionsSetName + Hierarchy, all classes + PBXProjectModuleGUID + 1CA6456E063B45B4001379D8 + PBXProjectModuleLabel + Class Browser - NSObject + + GeometryConfiguration + + ClassesFrame + {{0, 0}, {374, 96}} + ClassesTreeTableConfiguration + + PBXClassNameColumnIdentifier + 208 + PBXClassBookColumnIdentifier + 22 + + Frame + {{0, 0}, {630, 331}} + MembersFrame + {{0, 105}, {374, 395}} + MembersTreeTableConfiguration + + PBXMemberTypeIconColumnIdentifier + 22 + PBXMemberNameColumnIdentifier + 216 + PBXMemberTypeColumnIdentifier + 97 + PBXMemberBookColumnIdentifier + 22 + + PBXModuleWindowStatusBarHidden2 + 1 + RubberWindowFrame + 385 179 630 352 0 0 1440 878 + + Module + PBXClassBrowserModule + Proportion + 332pt + + + Proportion + 332pt + + + Name + Class Browser + ServiceClasses + + PBXClassBrowserModule + + StatusbarIsVisible + 0 + TableOfContents + + 1C0AD2AF069F1E9B00FABCE6 + 1C0AD2B0069F1E9B00FABCE6 + 1CA6456E063B45B4001379D8 + + ToolbarConfiguration + xcode.toolbar.config.classbrowser + WindowString + 385 179 630 352 0 0 1440 878 + WindowToolGUID + 1C0AD2AF069F1E9B00FABCE6 + WindowToolIsVisible + 0 + + + Identifier + windowTool.refactoring + IncludeInToolsMenu + 0 + Layout + + + Dock + + + BecomeActive + 1 + GeometryConfiguration + + Frame + {0, 0}, {500, 335} + RubberWindowFrame + {0, 0}, {500, 335} + + Module + XCRefactoringModule + Proportion + 100% + + + Proportion + 100% + + + Name + Refactoring + ServiceClasses + + XCRefactoringModule + + WindowString + 200 200 500 356 0 0 1920 1200 + + + + diff --git a/Sleep Blaster touch.xcodeproj/eamonford.pbxuser b/Sleep Blaster touch.xcodeproj/eamonford.pbxuser new file mode 100644 index 0000000..fdf3025 --- /dev/null +++ b/Sleep Blaster touch.xcodeproj/eamonford.pbxuser @@ -0,0 +1,786 @@ +// !$*UTF8*$! +{ + 1D3623240D0F684500981E51 /* Sleep_Blaster_touchAppDelegate.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {927, 900}}"; + sepNavSelRange = "{1303, 0}"; + sepNavVisRange = "{443, 1785}"; + sepNavWindowFrame = "{{294, 4}, {986, 774}}"; + }; + }; + 1D3623250D0F684500981E51 /* Sleep_Blaster_touchAppDelegate.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1167, 6285}}"; + sepNavSelRange = "{7365, 0}"; + sepNavVisRange = "{6189, 1730}"; + sepNavWindowFrame = "{{173, 5}, {1077, 773}}"; + }; + }; + 1D6058900D05DD3D006BFB54 /* Sleep Blaster touch */ = { + activeExec = 0; + executables = ( + E127F6450FDE410500833255 /* Sleep Blaster touch */, + ); + }; + 29B97313FDCFA39411CA2CEA /* Project object */ = { + activeArchitecturePreference = armv6; + activeBuildConfigurationName = Release; + activeExecutable = E127F6450FDE410500833255 /* Sleep Blaster touch */; + activeSDKPreference = iphonesimulator4.1; + activeTarget = 1D6058900D05DD3D006BFB54 /* Sleep Blaster touch */; + addToTargets = ( + 1D6058900D05DD3D006BFB54 /* Sleep Blaster touch */, + ); + breakpoints = ( + ); + codeSenseManager = E127F64C0FDE410C00833255 /* Code sense */; + executables = ( + E127F6450FDE410500833255 /* Sleep Blaster touch */, + ); + perUserDictionary = { + PBXConfiguration.PBXFileTableDataSource3.PBXBookmarksDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXBookmarksDataSource_NameID; + PBXFileTableDataSourceColumnWidthsKey = ( + 200, + 200, + 84, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXBookmarksDataSource_LocationID, + PBXBookmarksDataSource_NameID, + PBXBookmarksDataSource_CommentsID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID; + PBXFileTableDataSourceColumnWidthsKey = ( + 22, + 300, + 87, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXExecutablesDataSource_ActiveFlagID, + PBXExecutablesDataSource_NameID, + PBXExecutablesDataSource_CommentsID, + ); + }; + PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 193, + 20, + 48, + 43, + 43, + 20, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + PBXFileDataSource_Target_ColumnID, + ); + }; + PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 153, + 60, + 20, + 48, + 43, + 43, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXTargetDataSource_PrimaryAttribute, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + ); + }; + PBXPerProjectTemplateStateSaveDate = 309328659; + PBXWorkspaceStateSaveDate = 309328659; + }; + sourceControlManager = E127F64B0FDE410C00833255 /* Source Control */; + userBookmarkGroup = E10FE232121ED50300904361 /* PBXBookmarkGroup */; + userBuildSettings = { + }; + }; + 29B97316FDCFA39411CA2CEA /* main.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {927, 646}}"; + sepNavSelRange = "{365, 0}"; + sepNavVisRange = "{0, 365}"; + sepNavWindowFrame = "{{494, 4}, {986, 774}}"; + }; + }; + 8D1107310486CEB800E47090 /* Sleep_Blaster_touch-Info.plist */ = { + uiCtxt = { + sepNavWindowFrame = "{{351, 4}, {929, 774}}"; + }; + }; + E107C3D4115C9C5900BF4BCA /* TBFOceanWaveGenerator.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {870, 623}}"; + sepNavSelRange = "{526, 0}"; + sepNavVisRange = "{0, 532}"; + sepNavWindowFrame = "{{231, 4}, {929, 774}}"; + }; + }; + E107C3D5115C9C5900BF4BCA /* TBFOceanWaveGenerator.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1181, 1845}}"; + sepNavSelRange = "{2091, 0}"; + sepNavVisRange = "{274, 871}"; + sepNavWindowFrame = "{{334, 4}, {929, 774}}"; + }; + }; + E107C3E8115C9CA000BF4BCA /* Randomizer.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {924, 285}}"; + sepNavSelRange = "{176, 0}"; + sepNavVisRange = "{0, 252}"; + }; + }; + E10BCD481191429E0013C7BD /* MapDrawingViewController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1093, 646}}"; + sepNavSelRange = "{355, 119}"; + sepNavVisRange = "{0, 481}"; + sepNavWindowFrame = "{{119, 4}, {1152, 774}}"; + }; + }; + E10BCD491191429E0013C7BD /* MapDrawingViewController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1146, 2385}}"; + sepNavSelRange = "{4212, 0}"; + sepNavVisRange = "{3608, 1004}"; + sepNavWindowFrame = "{{51, 4}, {1152, 774}}"; + }; + }; + E10E4ED9116026A1006BD725 /* sleepTimerButton.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 25}, {1092, 748}}"; + }; + }; + E10E526711626EBB006BD725 /* alarmMiniLCD.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 25}, {1092, 748}}"; + }; + }; + E10FE232121ED50300904361 /* PBXBookmarkGroup */ = { + isa = PBXBookmarkGroup; + children = ( + E10FE27D121EF54300904361 /* PBXBookmark */, + ); + name = Root; + }; + E10FE27D121EF54300904361 /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = E1D3AE1D10BC8937001F61ED /* ClockView.xib */; + }; + E1102C49111369EE00CF462E /* SleepTimerSettingsViewController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1006, 975}}"; + sepNavSelRange = "{1768, 0}"; + sepNavVisRange = "{632, 1179}"; + sepNavWindowFrame = "{{279, 4}, {929, 774}}"; + }; + }; + E1102C4A111369EE00CF462E /* SleepTimerSettingsViewController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1135, 10800}}"; + sepNavSelRange = "{6190, 0}"; + sepNavVisRange = "{5626, 1577}"; + sepNavWindowFrame = "{{86, 4}, {1194, 774}}"; + }; + }; + E111306E0FE591160037335E /* AlarmSettingsViewController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1195, 990}}"; + sepNavSelRange = "{813, 0}"; + sepNavVisRange = "{0, 1296}"; + sepNavWindowFrame = "{{366, 4}, {914, 774}}"; + }; + }; + E111306F0FE591160037335E /* AlarmSettingsViewController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1104, 23130}}"; + sepNavSelRange = "{24842, 0}"; + sepNavVisRange = "{0, 653}"; + sepNavWindowFrame = "{{50, 4}, {1103, 774}}"; + }; + }; + E117E2BF10C39B5D006723EF /* ShadowedLabel.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {870, 646}}"; + sepNavSelRange = "{339, 0}"; + sepNavVisRange = "{0, 345}"; + sepNavWindowFrame = "{{15, 4}, {929, 774}}"; + }; + }; + E117E2C010C39B5D006723EF /* ShadowedLabel.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {870, 840}}"; + sepNavSelRange = "{537, 0}"; + sepNavVisRange = "{150, 933}"; + sepNavWindowFrame = "{{228, 4}, {929, 774}}"; + }; + }; + E11A30DA106C410600BE7E70 /* AlarmController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {779, 646}}"; + sepNavSelRange = "{418, 0}"; + sepNavVisRange = "{0, 898}"; + sepNavWindowFrame = "{{41, 4}, {838, 774}}"; + }; + }; + E11A30DB106C410600BE7E70 /* AlarmController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1244, 9870}}"; + sepNavSelRange = "{10715, 0}"; + sepNavVisRange = "{9527, 1800}"; + sepNavWindowFrame = "{{173, 4}, {1155, 774}}"; + }; + }; + E11B79B41170F6DE008CFF9B /* MapViewController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1135, 660}}"; + sepNavSelRange = "{572, 0}"; + sepNavVisRange = "{3, 1335}"; + sepNavWindowFrame = "{{86, 4}, {1194, 774}}"; + }; + }; + E11B79B51170F6DE008CFF9B /* MapViewController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1699, 8250}}"; + sepNavSelRange = "{7614, 0}"; + sepNavVisRange = "{6996, 1360}"; + sepNavWindowFrame = "{{188, 4}, {1092, 748}}"; + }; + }; + E11B7A0C1170FFD6008CFF9B /* MapAnnotationView.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1135, 623}}"; + sepNavSelRange = "{458, 0}"; + sepNavVisRange = "{0, 458}"; + sepNavWindowFrame = "{{15, 4}, {1194, 774}}"; + }; + }; + E11B7A0D1170FFD6008CFF9B /* MapAnnotationView.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1083, 2220}}"; + sepNavSelRange = "{1027, 0}"; + sepNavVisRange = "{841, 1456}"; + sepNavWindowFrame = "{{216, 4}, {882, 774}}"; + }; + }; + E11B7B26117145AC008CFF9B /* MapLinesAnnotation.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1135, 623}}"; + sepNavSelRange = "{499, 0}"; + sepNavVisRange = "{0, 505}"; + sepNavWindowFrame = "{{45, 4}, {1194, 774}}"; + }; + }; + E11B7B27117145AC008CFF9B /* MapLinesAnnotation.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {959, 885}}"; + sepNavSelRange = "{397, 0}"; + sepNavVisRange = "{223, 585}"; + sepNavWindowFrame = "{{74, 4}, {1194, 774}}"; + }; + }; + E11B7B5D11714FC5008CFF9B /* MapDrawingView.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1135, 646}}"; + sepNavSelRange = "{327, 0}"; + sepNavVisRange = "{0, 495}"; + sepNavWindowFrame = "{{0, 4}, {1194, 774}}"; + }; + }; + E11B7B5E11714FC5008CFF9B /* MapDrawingView.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1025, 2610}}"; + sepNavSelRange = "{3985, 0}"; + sepNavVisRange = "{3565, 747}"; + sepNavWindowFrame = "{{348, 6}, {823, 772}}"; + }; + }; + E11EA131123AF31D00BC86BA /* blueTrack.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E11EE29410E990C100342E69 /* ClockView.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {870, 623}}"; + sepNavSelRange = "{247, 0}"; + sepNavVisRange = "{0, 256}"; + sepNavWindowFrame = "{{15, 4}, {929, 774}}"; + }; + }; + E11EE29510E990C100342E69 /* ClockView.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {870, 1545}}"; + sepNavSelRange = "{2264, 0}"; + sepNavVisRange = "{1795, 1075}"; + sepNavWindowFrame = "{{341, 4}, {929, 774}}"; + }; + }; + E11EE33610EB26A900342E69 /* info.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{38, 4}, {1092, 748}}"; + }; + }; + E12348871184CB7700820805 /* mapBottomBar.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1266AB81223AFF500B92121 /* bell-iPad.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E127F6450FDE410500833255 /* Sleep Blaster touch */ = { + isa = PBXExecutable; + activeArgIndices = ( + ); + argumentStrings = ( + ); + autoAttachOnCrash = 1; + breakpointsEnabled = 0; + configStateDict = { + }; + customDataFormattersEnabled = 1; + dataTipCustomDataFormattersEnabled = 1; + dataTipShowTypeColumn = 1; + dataTipSortType = 0; + debuggerPlugin = GDBDebugging; + disassemblyDisplayState = 0; + dylibVariantSuffix = ""; + enableDebugStr = 1; + environmentEntries = ( + ); + executableSystemSymbolLevel = 0; + executableUserSymbolLevel = 0; + libgmallocEnabled = 0; + name = "Sleep Blaster touch"; + savedGlobals = { + }; + showTypeColumn = 0; + sourceDirectories = ( + ); + variableFormatDictionary = { + $lr = 1; + $pc = 1; + $r0 = 1; + $r1 = 1; + $r10 = 1; + $r11 = 1; + $r12 = 1; + $r2 = 1; + $r3 = 1; + $r4 = 1; + $r5 = 1; + $r6 = 1; + $r7 = 1; + $r8 = 1; + $r9 = 1; + $sp = 1; + }; + }; + E127F64B0FDE410C00833255 /* Source Control */ = { + isa = PBXSourceControlManager; + fallbackIsa = XCSourceControlManager; + isSCMEnabled = 0; + scmConfiguration = { + repositoryNamesForRoots = { + "" = ""; + }; + }; + }; + E127F64C0FDE410C00833255 /* Code sense */ = { + isa = PBXCodeSenseManager; + indexTemplatePath = ""; + }; + E1329DAA1090A8FD00787D98 /* DeepSleepPreventer.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {870, 623}}"; + sepNavSelRange = "{512, 0}"; + sepNavVisRange = "{0, 696}"; + sepNavWindowFrame = "{{297, 4}, {929, 774}}"; + }; + }; + E1329DAB1090A8FD00787D98 /* DeepSleepPreventer.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1209, 2205}}"; + sepNavSelRange = "{1491, 0}"; + sepNavVisRange = "{360, 1334}"; + sepNavWindowFrame = "{{162, 4}, {929, 774}}"; + }; + }; + E14143FA11EEDA9100273935 /* KeypadViewController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1096, 646}}"; + sepNavSelRange = "{299, 0}"; + sepNavVisRange = "{0, 419}"; + sepNavWindowFrame = "{{15, 4}, {1155, 774}}"; + }; + }; + E14143FB11EEDA9100273935 /* KeypadViewController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1146, 1455}}"; + sepNavSelRange = "{437, 0}"; + sepNavVisRange = "{288, 356}"; + sepNavWindowFrame = "{{21, 4}, {1155, 774}}"; + }; + }; + E141442E11EEE1D600273935 /* NSLocale+Misc.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1096, 646}}"; + sepNavSelRange = "{213, 0}"; + sepNavVisRange = "{0, 248}"; + sepNavWindowFrame = "{{89, 4}, {1155, 774}}"; + }; + }; + E141442F11EEE1D600273935 /* NSLocale+Misc.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1096, 646}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRange = "{0, 765}"; + sepNavWindowFrame = "{{72, 4}, {1155, 774}}"; + }; + }; + E17720851136CD44001FB7D7 /* VoiceSettingsViewController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {870, 646}}"; + sepNavSelRange = "{874, 0}"; + sepNavVisRange = "{0, 875}"; + sepNavWindowFrame = "{{351, 4}, {929, 774}}"; + }; + }; + E17720861136CD44001FB7D7 /* VoiceSettingsViewController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1146, 5970}}"; + sepNavSelRange = "{810, 136}"; + sepNavVisRange = "{381, 1179}"; + sepNavWindowFrame = "{{198, 4}, {929, 774}}"; + }; + }; + E17B68BD111779E90036C941 /* CustomUISwitch.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {957, 623}}"; + sepNavSelRange = "{547, 0}"; + sepNavVisRange = "{0, 933}"; + sepNavWindowFrame = "{{127, 4}, {929, 774}}"; + }; + }; + E17B68BE111779E90036C941 /* CustomUISwitch.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {959, 3240}}"; + sepNavSelRange = "{5215, 0}"; + sepNavVisRange = "{4820, 399}"; + sepNavWindowFrame = "{{260, 4}, {929, 774}}"; + }; + }; + E1875673118637E600656ADB /* clockIcon.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1152, 774}}"; + }; + }; + E18756891186764900656ADB /* hourGlassIcon.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 25}, {1092, 748}}"; + }; + }; + E1882D86122D8B45000901AB /* segmentedControlOceanWavesSelected.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1882D8A122D8B4B000901AB /* segmentedControlMusicDeselected.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1882D8E122D8BC5000901AB /* lightRowTop.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E19237BA11648D9F0034780C /* translucentScreen.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 25}, {1092, 748}}"; + }; + }; + E19237D91164969A0034780C /* rewind.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E192383F1165DBA90034780C /* NoArtwork.tif */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1152, 774}}"; + }; + }; + E19238721168854D0034780C /* stopSleepTimerButton.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{38, 4}, {1092, 748}}"; + }; + }; + E1973FDC103783CD0093AB67 /* AlarmRingingViewController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {927, 623}}"; + sepNavSelRange = "{567, 0}"; + sepNavVisRange = "{0, 573}"; + sepNavWindowFrame = "{{103, 4}, {986, 774}}"; + }; + }; + E1973FDD103783CD0093AB67 /* AlarmRingingViewController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1146, 1845}}"; + sepNavSelRange = "{1092, 0}"; + sepNavVisRange = "{333, 1699}"; + sepNavWindowFrame = "{{134, 4}, {986, 774}}"; + }; + }; + E1973FE41037862E0093AB67 /* TimeBar.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {986, 774}}"; + }; + }; + E19D466B0FED61A600553EE2 /* Constants.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1018, 622}}"; + sepNavSelRange = "{1188, 0}"; + sepNavVisRange = "{0, 1380}"; + sepNavWindowFrame = "{{16, 5}, {1077, 773}}"; + }; + }; + E1A1487B10D4A3B900840EBA /* bell.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {929, 774}}"; + }; + }; + E1A328D811889DAE006E9BAE /* currentLocationGlowing.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1A3294A1188D3C9006E9BAE /* findLine.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{38, 4}, {1092, 748}}"; + }; + }; + E1A3C7B01154451500BFEEB6 /* numericButton.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1A3C7B11154451500BFEEB6 /* numericButtonPressed.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1A3C7D0115446DD00BFEEB6 /* numericRedButtonPressed.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 25}, {1092, 748}}"; + }; + }; + E1A8D297118A072F00B53A6A /* alarmOffButton.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1152, 774}}"; + }; + }; + E1A8D299118A074200B53A6A /* snoozeButton.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1152, 774}}"; + }; + }; + E1A8D2FC118A1C1000B53A6A /* alarmRingingBottomBar.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 25}, {1092, 748}}"; + }; + }; + E1BEDDDD1239E99C009BD347 /* EmptyViewController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1044, 623}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRange = "{0, 242}"; + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1BEDDDE1239E99C009BD347 /* EmptyViewController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1044, 930}}"; + sepNavSelRange = "{329, 0}"; + sepNavVisRange = "{0, 975}"; + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C0E1E61240B3580074B386 /* Icon.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C3269612298F0A00208ADC /* indicatorLightOff-iPad.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C326B91229B48200208ADC /* indicatorLightOn-iPad.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C327171229D12900208ADC /* disclosure-iPad.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C327E1122A55BE00208ADC /* blackScreen.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C32900122B178200208ADC /* Icon-72.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C32914122B474800208ADC /* lightTexturedBackground.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C32995122B9B0F00208ADC /* segmentedControlStop.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C32997122B9B1500208ADC /* segmentedControlSnooze.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C3AC7C12400DED00697B56 /* clockView-iPad.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C3ACF51240978A00697B56 /* Icon@2x.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C842B01228B61E0016D705 /* switch_on_lighter.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 25}, {1092, 748}}"; + }; + }; + E1C842B41228B6C20016D705 /* switch_off_lighter.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C842C31228B8230016D705 /* switch_lighter.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1C850DE1231C273004D23F6 /* segmentedControlPlaceSelected.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; + E1CB6CFC101E8CB40008188B /* SCListener.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {927, 623}}"; + sepNavSelRange = "{433, 0}"; + sepNavVisRange = "{0, 626}"; + sepNavWindowFrame = "{{202, 4}, {986, 774}}"; + }; + }; + E1CB6CFD101E8CB40008188B /* SCListener.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1559, 3630}}"; + sepNavSelRange = "{903, 0}"; + sepNavVisRange = "{604, 421}"; + sepNavWindowFrame = "{{283, 4}, {986, 774}}"; + }; + }; + E1CD26BD115A9CA600D26D79 /* SleepTimerController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {870, 646}}"; + sepNavSelRange = "{654, 0}"; + sepNavVisRange = "{0, 654}"; + sepNavWindowFrame = "{{351, 4}, {929, 774}}"; + }; + }; + E1CD26BE115A9CA600D26D79 /* SleepTimerController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {992, 2865}}"; + sepNavSelRange = "{3448, 0}"; + sepNavVisRange = "{2830, 1633}"; + sepNavWindowFrame = "{{216, 4}, {929, 774}}"; + }; + }; + E1D3AE1B10BC8937001F61ED /* ClockViewController.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {870, 1155}}"; + sepNavSelRange = "{1723, 0}"; + sepNavVisRange = "{0, 1444}"; + sepNavWindowFrame = "{{111, 4}, {929, 774}}"; + }; + }; + E1D3AE1C10BC8937001F61ED /* ClockViewController.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1167, 8415}}"; + sepNavSelRange = "{11214, 0}"; + sepNavVisRange = "{16776, 1473}"; + sepNavWindowFrame = "{{295, 4}, {929, 774}}"; + }; + }; + E1D3AE1D10BC8937001F61ED /* ClockView.xib */ = { + isa = PBXFileReference; + lastKnownFileType = file.xib; + name = ClockView.xib; + path = "/Users/eamonford/Desktop/Sleep Blaster touch/ClockView.xib"; + sourceTree = ""; + }; + E1DB6D37117F99720089CC1A /* BlackSegmentedControl.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1093, 646}}"; + sepNavSelRange = "{237, 0}"; + sepNavVisRange = "{0, 249}"; + sepNavWindowFrame = "{{15, 4}, {1152, 774}}"; + }; + }; + E1DB6D38117F99720089CC1A /* BlackSegmentedControl.m */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1093, 660}}"; + sepNavSelRange = "{588, 0}"; + sepNavVisRange = "{3, 640}"; + sepNavWindowFrame = "{{15, 4}, {1152, 774}}"; + }; + }; + E1EDCE571226F6AD005F3467 /* keypadBackground.png */ = { + uiCtxt = { + sepNavWindowFrame = "{{15, 4}, {1103, 774}}"; + }; + }; +} diff --git a/Sleep Blaster touch.xcodeproj/project.pbxproj b/Sleep Blaster touch.xcodeproj/project.pbxproj new file mode 100644 index 0000000..5bfb567 --- /dev/null +++ b/Sleep Blaster touch.xcodeproj/project.pbxproj @@ -0,0 +1,846 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 1D3623260D0F684500981E51 /* Sleep_Blaster_touchAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* Sleep_Blaster_touchAppDelegate.m */; }; + 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; + 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; + E107C3D3115C9C3D00BF4BCA /* pinkNoise.m4a in Resources */ = {isa = PBXBuildFile; fileRef = E107C3D2115C9C3D00BF4BCA /* pinkNoise.m4a */; }; + E107C3D6115C9C5900BF4BCA /* TBFOceanWaveGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = E107C3D5115C9C5900BF4BCA /* TBFOceanWaveGenerator.m */; }; + E107C3EA115C9CA000BF4BCA /* Randomizer.m in Sources */ = {isa = PBXBuildFile; fileRef = E107C3E9115C9CA000BF4BCA /* Randomizer.m */; }; + E10822A91075C60A0017B639 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E10822A81075C60A0017B639 /* QuartzCore.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + E10BCD4A1191429E0013C7BD /* MapDrawingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E10BCD491191429E0013C7BD /* MapDrawingViewController.m */; }; + E10E4EDA116026A1006BD725 /* sleepTimerButton.png in Resources */ = {isa = PBXBuildFile; fileRef = E10E4ED9116026A1006BD725 /* sleepTimerButton.png */; }; + E10E526811626EBB006BD725 /* alarmMiniLCD.png in Resources */ = {isa = PBXBuildFile; fileRef = E10E526711626EBB006BD725 /* alarmMiniLCD.png */; }; + E1102C4C111369EE00CF462E /* SleepTimerSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1102C4A111369EE00CF462E /* SleepTimerSettingsViewController.m */; }; + E1102C4D111369EE00CF462E /* SleepTimerSettingsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E1102C4B111369EE00CF462E /* SleepTimerSettingsView.xib */; }; + E11130700FE591160037335E /* AlarmSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E111306F0FE591160037335E /* AlarmSettingsViewController.m */; }; + E11130790FE5925B0037335E /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E11130780FE5925B0037335E /* MediaPlayer.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + E1136F1310BF63B100CB9E67 /* digital-7.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E1136F1210BF63B100CB9E67 /* digital-7.ttf */; }; + E117E2C110C39B5D006723EF /* ShadowedLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = E117E2C010C39B5D006723EF /* ShadowedLabel.m */; }; + E1183DDF0FF846EC003850BF /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1183DDE0FF846EC003850BF /* AudioToolbox.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + E1183DE30FF84707003850BF /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1183DE20FF84707003850BF /* CoreFoundation.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + E11A30DC106C410600BE7E70 /* AlarmController.m in Sources */ = {isa = PBXBuildFile; fileRef = E11A30DB106C410600BE7E70 /* AlarmController.m */; }; + E11B79B71170F6DE008CFF9B /* MapViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E11B79B51170F6DE008CFF9B /* MapViewController.m */; }; + E11B79B81170F6DE008CFF9B /* MapView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E11B79B61170F6DE008CFF9B /* MapView.xib */; }; + E11B79FD1170FB39008CFF9B /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E11B79FC1170FB39008CFF9B /* MapKit.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + E11B7A0E1170FFD6008CFF9B /* MapAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = E11B7A0D1170FFD6008CFF9B /* MapAnnotationView.m */; }; + E11B7B28117145AC008CFF9B /* MapLinesAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = E11B7B27117145AC008CFF9B /* MapLinesAnnotation.m */; }; + E11B7B5F11714FC5008CFF9B /* MapDrawingView.m in Sources */ = {isa = PBXBuildFile; fileRef = E11B7B5E11714FC5008CFF9B /* MapDrawingView.m */; }; + E11B7BBB11715DD5008CFF9B /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E11B7BBA11715DD5008CFF9B /* CoreLocation.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + E11EA134123AF31D00BC86BA /* blueTrack.png in Resources */ = {isa = PBXBuildFile; fileRef = E11EA131123AF31D00BC86BA /* blueTrack.png */; }; + E11EA135123AF31D00BC86BA /* whiteSlide.png in Resources */ = {isa = PBXBuildFile; fileRef = E11EA132123AF31D00BC86BA /* whiteSlide.png */; }; + E11EA136123AF31D00BC86BA /* whiteTrack.png in Resources */ = {isa = PBXBuildFile; fileRef = E11EA133123AF31D00BC86BA /* whiteTrack.png */; }; + E11EE29610E990C100342E69 /* ClockView.m in Sources */ = {isa = PBXBuildFile; fileRef = E11EE29510E990C100342E69 /* ClockView.m */; }; + E11EE33710EB26A900342E69 /* info.png in Resources */ = {isa = PBXBuildFile; fileRef = E11EE33610EB26A900342E69 /* info.png */; }; + E12348881184CB7700820805 /* mapBottomBar.png in Resources */ = {isa = PBXBuildFile; fileRef = E12348871184CB7700820805 /* mapBottomBar.png */; }; + E1266AB91223AFF500B92121 /* bell-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = E1266AB81223AFF500B92121 /* bell-iPad.png */; }; + E1266B8A1224EEF500B92121 /* AlarmSettingsView-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = E1266B891224EEF500B92121 /* AlarmSettingsView-iPad.xib */; }; + E1266BC31224FAC800B92121 /* MainWindow-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = E1266BC21224FAC800B92121 /* MainWindow-iPad.xib */; }; + E1266BE51225003F00B92121 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = E1266BE41225003F00B92121 /* MainWindow.xib */; }; + E1329D1D108EF09700787D98 /* explosion.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = E1329D1C108EF09700787D98 /* explosion.mp3 */; }; + E1329DA91090A8CC00787D98 /* noSound.wav in Resources */ = {isa = PBXBuildFile; fileRef = E1329DA81090A8CC00787D98 /* noSound.wav */; }; + E1329DAC1090A8FD00787D98 /* DeepSleepPreventer.m in Sources */ = {isa = PBXBuildFile; fileRef = E1329DAB1090A8FD00787D98 /* DeepSleepPreventer.m */; }; + E14143FD11EEDA9100273935 /* KeypadViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E14143FB11EEDA9100273935 /* KeypadViewController.m */; }; + E14143FE11EEDA9100273935 /* KeypadView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E14143FC11EEDA9100273935 /* KeypadView.xib */; }; + E141443011EEE1D600273935 /* NSLocale+Misc.m in Sources */ = {isa = PBXBuildFile; fileRef = E141442F11EEE1D600273935 /* NSLocale+Misc.m */; }; + E15428ED10D0B57A0042935C /* digital-7 (italic).ttf in Resources */ = {isa = PBXBuildFile; fileRef = E15428EC10D0B57A0042935C /* digital-7 (italic).ttf */; }; + E17720881136CD44001FB7D7 /* VoiceSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E17720861136CD44001FB7D7 /* VoiceSettingsViewController.m */; }; + E17720891136CD44001FB7D7 /* VoiceSettingsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E17720871136CD44001FB7D7 /* VoiceSettingsView.xib */; }; + E17B68BF111779E90036C941 /* CustomUISwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = E17B68BE111779E90036C941 /* CustomUISwitch.m */; }; + E187560B118574CF00656ADB /* redDrawButton.png in Resources */ = {isa = PBXBuildFile; fileRef = E187560A118574CF00656ADB /* redDrawButton.png */; }; + E1875654118615E800656ADB /* redDrawButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = E1875653118615E800656ADB /* redDrawButtonPressed.png */; }; + E1875674118637E600656ADB /* clockIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = E1875673118637E600656ADB /* clockIcon.png */; }; + E187568A1186764900656ADB /* hourGlassIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = E18756891186764900656ADB /* hourGlassIcon.png */; }; + E18756C31186A47B00656ADB /* currentLocation.png in Resources */ = {isa = PBXBuildFile; fileRef = E18756C21186A47B00656ADB /* currentLocation.png */; }; + E1882D87122D8B45000901AB /* segmentedControlOceanWavesDeselected.png in Resources */ = {isa = PBXBuildFile; fileRef = E1882D84122D8B45000901AB /* segmentedControlOceanWavesDeselected.png */; }; + E1882D88122D8B45000901AB /* segmentedControlMusicSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = E1882D85122D8B45000901AB /* segmentedControlMusicSelected.png */; }; + E1882D89122D8B45000901AB /* segmentedControlOceanWavesSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = E1882D86122D8B45000901AB /* segmentedControlOceanWavesSelected.png */; }; + E1882D8B122D8B4B000901AB /* segmentedControlMusicDeselected.png in Resources */ = {isa = PBXBuildFile; fileRef = E1882D8A122D8B4B000901AB /* segmentedControlMusicDeselected.png */; }; + E1882D8F122D8BC5000901AB /* lightRowTop.png in Resources */ = {isa = PBXBuildFile; fileRef = E1882D8E122D8BC5000901AB /* lightRowTop.png */; }; + E19237BB11648D9F0034780C /* translucentScreen.png in Resources */ = {isa = PBXBuildFile; fileRef = E19237BA11648D9F0034780C /* translucentScreen.png */; }; + E19237D8116496630034780C /* fastForward.png in Resources */ = {isa = PBXBuildFile; fileRef = E19237D7116496630034780C /* fastForward.png */; }; + E19237DA1164969A0034780C /* rewind.png in Resources */ = {isa = PBXBuildFile; fileRef = E19237D91164969A0034780C /* rewind.png */; }; + E19238401165DBA90034780C /* NoArtwork.tif in Resources */ = {isa = PBXBuildFile; fileRef = E192383F1165DBA90034780C /* NoArtwork.tif */; }; + E19238731168854D0034780C /* stopSleepTimerButton.png in Resources */ = {isa = PBXBuildFile; fileRef = E19238721168854D0034780C /* stopSleepTimerButton.png */; }; + E1973FDF103783CD0093AB67 /* AlarmRingingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1973FDD103783CD0093AB67 /* AlarmRingingViewController.m */; }; + E1973FE0103783CD0093AB67 /* AlarmRingingView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E1973FDE103783CD0093AB67 /* AlarmRingingView.xib */; }; + E1973FE71037862E0093AB67 /* TimeBar.png in Resources */ = {isa = PBXBuildFile; fileRef = E1973FE41037862E0093AB67 /* TimeBar.png */; }; + E19DFACC12512081009763EA /* beep.wav in Resources */ = {isa = PBXBuildFile; fileRef = E19DFACB12512081009763EA /* beep.wav */; }; + E19DFC12125D8646009763EA /* silent.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = E19DFC11125D8646009763EA /* silent.mp3 */; }; + E1A1487C10D4A3B900840EBA /* bell.png in Resources */ = {isa = PBXBuildFile; fileRef = E1A1487B10D4A3B900840EBA /* bell.png */; }; + E1A328D911889DAE006E9BAE /* currentLocationGlowing.png in Resources */ = {isa = PBXBuildFile; fileRef = E1A328D811889DAE006E9BAE /* currentLocationGlowing.png */; }; + E1A3294B1188D3C9006E9BAE /* findLine.png in Resources */ = {isa = PBXBuildFile; fileRef = E1A3294A1188D3C9006E9BAE /* findLine.png */; }; + E1A3C7B21154451500BFEEB6 /* numericButton.png in Resources */ = {isa = PBXBuildFile; fileRef = E1A3C7B01154451500BFEEB6 /* numericButton.png */; }; + E1A3C7B31154451500BFEEB6 /* numericButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = E1A3C7B11154451500BFEEB6 /* numericButtonPressed.png */; }; + E1A3C7BB1154465A00BFEEB6 /* numericBlueButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = E1A3C7B91154465A00BFEEB6 /* numericBlueButtonPressed.png */; }; + E1A3C7D2115446DD00BFEEB6 /* numericRedButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = E1A3C7D0115446DD00BFEEB6 /* numericRedButtonPressed.png */; }; + E1A400BB1027CDA200A5AB67 /* alarm.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = E1A400BA1027CDA200A5AB67 /* alarm.mp3 */; }; + E1A400CC1027CF4E00A5AB67 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1A400CB1027CF4E00A5AB67 /* AVFoundation.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + E1A84AF0124DE466008AA3D6 /* MapView-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = E1A84AEF124DE466008AA3D6 /* MapView-iPad.xib */; }; + E1A8D298118A072F00B53A6A /* alarmOffButton.png in Resources */ = {isa = PBXBuildFile; fileRef = E1A8D297118A072F00B53A6A /* alarmOffButton.png */; }; + E1A8D29A118A074200B53A6A /* snoozeButton.png in Resources */ = {isa = PBXBuildFile; fileRef = E1A8D299118A074200B53A6A /* snoozeButton.png */; }; + E1A8D2FD118A1C1000B53A6A /* alarmRingingBottomBar.png in Resources */ = {isa = PBXBuildFile; fileRef = E1A8D2FC118A1C1000B53A6A /* alarmRingingBottomBar.png */; }; + E1B427A61135B18D0002AF2D /* AlarmSettingsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E1B427A51135B18D0002AF2D /* AlarmSettingsView.xib */; }; + E1BEDDDF1239E99C009BD347 /* EmptyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1BEDDDE1239E99C009BD347 /* EmptyViewController.m */; }; + E1BEDF25123A28A6009BD347 /* blackGlass.png in Resources */ = {isa = PBXBuildFile; fileRef = E1BEDF24123A28A6009BD347 /* blackGlass.png */; }; + E1C0E1E71240B3580074B386 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C0E1E61240B3580074B386 /* Icon.png */; }; + E1C3269712298F0A00208ADC /* indicatorLightOff-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C3269612298F0A00208ADC /* indicatorLightOff-iPad.png */; }; + E1C326BA1229B48200208ADC /* indicatorLightOn-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C326B91229B48200208ADC /* indicatorLightOn-iPad.png */; }; + E1C327181229D12900208ADC /* disclosure-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C327171229D12900208ADC /* disclosure-iPad.png */; }; + E1C327E2122A55BE00208ADC /* blackScreen.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C327E1122A55BE00208ADC /* blackScreen.png */; }; + E1C32901122B178200208ADC /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C32900122B178200208ADC /* Icon-72.png */; }; + E1C32915122B474800208ADC /* lightTexturedBackground.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C32914122B474800208ADC /* lightTexturedBackground.png */; }; + E1C3292C122B4ABE00208ADC /* VoiceSettingsView-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = E1C3292B122B4ABE00208ADC /* VoiceSettingsView-iPad.xib */; }; + E1C32988122B965600208ADC /* segmentedControlSnoozeSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C32987122B965600208ADC /* segmentedControlSnoozeSelected.png */; }; + E1C3298A122B965900208ADC /* segmentedControlStopSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C32989122B965900208ADC /* segmentedControlStopSelected.png */; }; + E1C32996122B9B0F00208ADC /* segmentedControlStop.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C32995122B9B0F00208ADC /* segmentedControlStop.png */; }; + E1C32998122B9B1500208ADC /* segmentedControlSnooze.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C32997122B9B1500208ADC /* segmentedControlSnooze.png */; }; + E1C32A1E122CC6CF00208ADC /* SleepTimerSettingsView-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = E1C32A1D122CC6CF00208ADC /* SleepTimerSettingsView-iPad.xib */; }; + E1C3AC7D12400DED00697B56 /* clockView-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C3AC7C12400DED00697B56 /* clockView-iPad.png */; }; + E1C3AC821240105B00697B56 /* ClockView.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C3AC811240105B00697B56 /* ClockView.png */; }; + E1C3ACCA12408DB200697B56 /* numericBlueButton.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C3ACC912408DB200697B56 /* numericBlueButton.png */; }; + E1C3ACD612408F9500697B56 /* numericRedButton.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C3ACD512408F9500697B56 /* numericRedButton.png */; }; + E1C3ACF61240978A00697B56 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C3ACF51240978A00697B56 /* Icon@2x.png */; }; + E1C84245122874F70016D705 /* lightRow.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C84244122874F70016D705 /* lightRow.png */; }; + E1C842B11228B61E0016D705 /* switch_on_lighter.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C842B01228B61E0016D705 /* switch_on_lighter.png */; }; + E1C842B51228B6C20016D705 /* switch_off_lighter.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C842B41228B6C20016D705 /* switch_off_lighter.png */; }; + E1C842C41228B8230016D705 /* switch_lighter.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C842C31228B8230016D705 /* switch_lighter.png */; }; + E1C850E21231C273004D23F6 /* segmentedControlPlaceSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C850DE1231C273004D23F6 /* segmentedControlPlaceSelected.png */; }; + E1C850E31231C273004D23F6 /* segmentedControlTimeDeselected.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C850DF1231C273004D23F6 /* segmentedControlTimeDeselected.png */; }; + E1C850E41231C273004D23F6 /* segmentedControlPlaceDeselected.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C850E01231C273004D23F6 /* segmentedControlPlaceDeselected.png */; }; + E1C850E51231C273004D23F6 /* segmentedControlTimeSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = E1C850E11231C273004D23F6 /* segmentedControlTimeSelected.png */; }; + E1CB6CFE101E8CB40008188B /* SCListener.m in Sources */ = {isa = PBXBuildFile; fileRef = E1CB6CFD101E8CB40008188B /* SCListener.m */; }; + E1CD26BF115A9CA600D26D79 /* SleepTimerController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1CD26BE115A9CA600D26D79 /* SleepTimerController.m */; }; + E1D3AE1E10BC8937001F61ED /* ClockViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1D3AE1C10BC8937001F61ED /* ClockViewController.m */; }; + E1D95FF0126FFBE90028142E /* info@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E1D95FEF126FFBE90028142E /* info@2x.png */; }; + E1DB6D39117F99720089CC1A /* BlackSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = E1DB6D38117F99720089CC1A /* BlackSegmentedControl.m */; }; + E1E26CF610057ED000896840 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1E26CF510057ED000896840 /* CoreGraphics.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + E1EDCE581226F6AD005F3467 /* keypadBackground.png in Resources */ = {isa = PBXBuildFile; fileRef = E1EDCE571226F6AD005F3467 /* keypadBackground.png */; }; + E1F36C3A118FB38B001B31ED /* dynamite.png in Resources */ = {isa = PBXBuildFile; fileRef = E1F36C39118FB38B001B31ED /* dynamite.png */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 1D3623240D0F684500981E51 /* Sleep_Blaster_touchAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sleep_Blaster_touchAppDelegate.h; sourceTree = ""; }; + 1D3623250D0F684500981E51 /* Sleep_Blaster_touchAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Sleep_Blaster_touchAppDelegate.m; sourceTree = ""; }; + 1D6058910D05DD3D006BFB54 /* Sleep Blaster touch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Sleep Blaster touch.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 28A0AB4B0D9B1048005BE974 /* Sleep_Blaster_touch_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sleep_Blaster_touch_Prefix.pch; sourceTree = ""; }; + 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 8D1107310486CEB800E47090 /* Sleep_Blaster_touch-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Sleep_Blaster_touch-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; + E107C3D2115C9C3D00BF4BCA /* pinkNoise.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = pinkNoise.m4a; sourceTree = ""; }; + E107C3D4115C9C5900BF4BCA /* TBFOceanWaveGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TBFOceanWaveGenerator.h; sourceTree = ""; }; + E107C3D5115C9C5900BF4BCA /* TBFOceanWaveGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TBFOceanWaveGenerator.m; sourceTree = ""; }; + E107C3E8115C9CA000BF4BCA /* Randomizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Randomizer.h; sourceTree = ""; }; + E107C3E9115C9CA000BF4BCA /* Randomizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Randomizer.m; sourceTree = ""; }; + E10822A81075C60A0017B639 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + E10BCD481191429E0013C7BD /* MapDrawingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapDrawingViewController.h; sourceTree = ""; }; + E10BCD491191429E0013C7BD /* MapDrawingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapDrawingViewController.m; sourceTree = ""; }; + E10E4ED9116026A1006BD725 /* sleepTimerButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = sleepTimerButton.png; sourceTree = ""; }; + E10E526711626EBB006BD725 /* alarmMiniLCD.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = alarmMiniLCD.png; sourceTree = ""; }; + E1102C49111369EE00CF462E /* SleepTimerSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SleepTimerSettingsViewController.h; sourceTree = ""; }; + E1102C4A111369EE00CF462E /* SleepTimerSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SleepTimerSettingsViewController.m; sourceTree = ""; }; + E1102C4B111369EE00CF462E /* SleepTimerSettingsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SleepTimerSettingsView.xib; sourceTree = ""; }; + E111306E0FE591160037335E /* AlarmSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AlarmSettingsViewController.h; path = Classes/AlarmSettingsViewController.h; sourceTree = ""; }; + E111306F0FE591160037335E /* AlarmSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AlarmSettingsViewController.m; path = Classes/AlarmSettingsViewController.m; sourceTree = ""; }; + E11130780FE5925B0037335E /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; }; + E1136F1210BF63B100CB9E67 /* digital-7.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "digital-7.ttf"; sourceTree = ""; }; + E117E2BF10C39B5D006723EF /* ShadowedLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShadowedLabel.h; sourceTree = ""; }; + E117E2C010C39B5D006723EF /* ShadowedLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShadowedLabel.m; sourceTree = ""; }; + E1183DDE0FF846EC003850BF /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + E1183DE20FF84707003850BF /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; + E11A30DA106C410600BE7E70 /* AlarmController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlarmController.h; sourceTree = ""; }; + E11A30DB106C410600BE7E70 /* AlarmController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AlarmController.m; sourceTree = ""; }; + E11B79B41170F6DE008CFF9B /* MapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapViewController.h; sourceTree = ""; }; + E11B79B51170F6DE008CFF9B /* MapViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapViewController.m; sourceTree = ""; }; + E11B79B61170F6DE008CFF9B /* MapView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MapView.xib; sourceTree = ""; }; + E11B79FC1170FB39008CFF9B /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; + E11B7A0C1170FFD6008CFF9B /* MapAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapAnnotationView.h; sourceTree = ""; }; + E11B7A0D1170FFD6008CFF9B /* MapAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapAnnotationView.m; sourceTree = ""; }; + E11B7B26117145AC008CFF9B /* MapLinesAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapLinesAnnotation.h; sourceTree = ""; }; + E11B7B27117145AC008CFF9B /* MapLinesAnnotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapLinesAnnotation.m; sourceTree = ""; }; + E11B7B5D11714FC5008CFF9B /* MapDrawingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapDrawingView.h; sourceTree = ""; }; + E11B7B5E11714FC5008CFF9B /* MapDrawingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapDrawingView.m; sourceTree = ""; }; + E11B7BBA11715DD5008CFF9B /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; + E11EA131123AF31D00BC86BA /* blueTrack.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = blueTrack.png; sourceTree = ""; }; + E11EA132123AF31D00BC86BA /* whiteSlide.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = whiteSlide.png; sourceTree = ""; }; + E11EA133123AF31D00BC86BA /* whiteTrack.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = whiteTrack.png; sourceTree = ""; }; + E11EE29410E990C100342E69 /* ClockView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClockView.h; sourceTree = ""; }; + E11EE29510E990C100342E69 /* ClockView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClockView.m; sourceTree = ""; }; + E11EE33610EB26A900342E69 /* info.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = info.png; sourceTree = ""; }; + E12348871184CB7700820805 /* mapBottomBar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = mapBottomBar.png; sourceTree = ""; }; + E1266AB81223AFF500B92121 /* bell-iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "bell-iPad.png"; sourceTree = ""; }; + E1266B891224EEF500B92121 /* AlarmSettingsView-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = "AlarmSettingsView-iPad.xib"; sourceTree = ""; }; + E1266BC21224FAC800B92121 /* MainWindow-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = "MainWindow-iPad.xib"; sourceTree = ""; }; + E1266BE41225003F00B92121 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; + E1329D1C108EF09700787D98 /* explosion.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = explosion.mp3; sourceTree = ""; }; + E1329DA81090A8CC00787D98 /* noSound.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = noSound.wav; sourceTree = ""; }; + E1329DAA1090A8FD00787D98 /* DeepSleepPreventer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeepSleepPreventer.h; sourceTree = ""; }; + E1329DAB1090A8FD00787D98 /* DeepSleepPreventer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DeepSleepPreventer.m; sourceTree = ""; }; + E14143FA11EEDA9100273935 /* KeypadViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeypadViewController.h; sourceTree = ""; }; + E14143FB11EEDA9100273935 /* KeypadViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KeypadViewController.m; sourceTree = ""; }; + E14143FC11EEDA9100273935 /* KeypadView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KeypadView.xib; sourceTree = ""; }; + E141442E11EEE1D600273935 /* NSLocale+Misc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSLocale+Misc.h"; path = "../NSLocale+Misc.h"; sourceTree = ""; }; + E141442F11EEE1D600273935 /* NSLocale+Misc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSLocale+Misc.m"; path = "../NSLocale+Misc.m"; sourceTree = ""; }; + E15428EC10D0B57A0042935C /* digital-7 (italic).ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "digital-7 (italic).ttf"; sourceTree = ""; }; + E17720851136CD44001FB7D7 /* VoiceSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VoiceSettingsViewController.h; sourceTree = ""; }; + E17720861136CD44001FB7D7 /* VoiceSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VoiceSettingsViewController.m; sourceTree = ""; }; + E17720871136CD44001FB7D7 /* VoiceSettingsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VoiceSettingsView.xib; sourceTree = ""; }; + E17B68BD111779E90036C941 /* CustomUISwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomUISwitch.h; sourceTree = ""; }; + E17B68BE111779E90036C941 /* CustomUISwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomUISwitch.m; sourceTree = ""; }; + E187560A118574CF00656ADB /* redDrawButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = redDrawButton.png; sourceTree = ""; }; + E1875653118615E800656ADB /* redDrawButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = redDrawButtonPressed.png; sourceTree = ""; }; + E1875673118637E600656ADB /* clockIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = clockIcon.png; sourceTree = ""; }; + E18756891186764900656ADB /* hourGlassIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = hourGlassIcon.png; sourceTree = ""; }; + E18756C21186A47B00656ADB /* currentLocation.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = currentLocation.png; sourceTree = ""; }; + E1882D84122D8B45000901AB /* segmentedControlOceanWavesDeselected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlOceanWavesDeselected.png; sourceTree = ""; }; + E1882D85122D8B45000901AB /* segmentedControlMusicSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlMusicSelected.png; sourceTree = ""; }; + E1882D86122D8B45000901AB /* segmentedControlOceanWavesSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlOceanWavesSelected.png; sourceTree = ""; }; + E1882D8A122D8B4B000901AB /* segmentedControlMusicDeselected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlMusicDeselected.png; sourceTree = ""; }; + E1882D8E122D8BC5000901AB /* lightRowTop.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = lightRowTop.png; sourceTree = ""; }; + E19237BA11648D9F0034780C /* translucentScreen.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = translucentScreen.png; sourceTree = ""; }; + E19237D7116496630034780C /* fastForward.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fastForward.png; sourceTree = ""; }; + E19237D91164969A0034780C /* rewind.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rewind.png; sourceTree = ""; }; + E192383F1165DBA90034780C /* NoArtwork.tif */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = NoArtwork.tif; sourceTree = ""; }; + E19238721168854D0034780C /* stopSleepTimerButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = stopSleepTimerButton.png; sourceTree = ""; }; + E1973FDC103783CD0093AB67 /* AlarmRingingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlarmRingingViewController.h; sourceTree = ""; }; + E1973FDD103783CD0093AB67 /* AlarmRingingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AlarmRingingViewController.m; sourceTree = ""; }; + E1973FDE103783CD0093AB67 /* AlarmRingingView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AlarmRingingView.xib; sourceTree = ""; }; + E1973FE41037862E0093AB67 /* TimeBar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = TimeBar.png; sourceTree = ""; }; + E19D466B0FED61A600553EE2 /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = ""; }; + E19DFACB12512081009763EA /* beep.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = beep.wav; sourceTree = ""; }; + E19DFC11125D8646009763EA /* silent.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = silent.mp3; sourceTree = ""; }; + E1A1487B10D4A3B900840EBA /* bell.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = bell.png; sourceTree = ""; }; + E1A328D811889DAE006E9BAE /* currentLocationGlowing.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = currentLocationGlowing.png; sourceTree = ""; }; + E1A3294A1188D3C9006E9BAE /* findLine.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = findLine.png; sourceTree = ""; }; + E1A3C7B01154451500BFEEB6 /* numericButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = numericButton.png; sourceTree = ""; }; + E1A3C7B11154451500BFEEB6 /* numericButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = numericButtonPressed.png; sourceTree = ""; }; + E1A3C7B91154465A00BFEEB6 /* numericBlueButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = numericBlueButtonPressed.png; sourceTree = ""; }; + E1A3C7D0115446DD00BFEEB6 /* numericRedButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = numericRedButtonPressed.png; sourceTree = ""; }; + E1A400BA1027CDA200A5AB67 /* alarm.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = alarm.mp3; sourceTree = ""; }; + E1A400CB1027CF4E00A5AB67 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + E1A84AEF124DE466008AA3D6 /* MapView-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = "MapView-iPad.xib"; sourceTree = ""; }; + E1A8D297118A072F00B53A6A /* alarmOffButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = alarmOffButton.png; sourceTree = ""; }; + E1A8D299118A074200B53A6A /* snoozeButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = snoozeButton.png; sourceTree = ""; }; + E1A8D2FC118A1C1000B53A6A /* alarmRingingBottomBar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = alarmRingingBottomBar.png; sourceTree = ""; }; + E1B427A51135B18D0002AF2D /* AlarmSettingsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AlarmSettingsView.xib; sourceTree = ""; }; + E1BEDDDD1239E99C009BD347 /* EmptyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmptyViewController.h; path = Classes/EmptyViewController.h; sourceTree = ""; }; + E1BEDDDE1239E99C009BD347 /* EmptyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = EmptyViewController.m; path = Classes/EmptyViewController.m; sourceTree = ""; }; + E1BEDF24123A28A6009BD347 /* blackGlass.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = blackGlass.png; sourceTree = ""; }; + E1C0E1E61240B3580074B386 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; }; + E1C3269612298F0A00208ADC /* indicatorLightOff-iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "indicatorLightOff-iPad.png"; sourceTree = ""; }; + E1C326B91229B48200208ADC /* indicatorLightOn-iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "indicatorLightOn-iPad.png"; sourceTree = ""; }; + E1C327171229D12900208ADC /* disclosure-iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "disclosure-iPad.png"; sourceTree = ""; }; + E1C327E1122A55BE00208ADC /* blackScreen.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = blackScreen.png; sourceTree = ""; }; + E1C32900122B178200208ADC /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; + E1C32914122B474800208ADC /* lightTexturedBackground.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = lightTexturedBackground.png; sourceTree = ""; }; + E1C3292B122B4ABE00208ADC /* VoiceSettingsView-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = "VoiceSettingsView-iPad.xib"; sourceTree = ""; }; + E1C32987122B965600208ADC /* segmentedControlSnoozeSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlSnoozeSelected.png; sourceTree = ""; }; + E1C32989122B965900208ADC /* segmentedControlStopSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlStopSelected.png; sourceTree = ""; }; + E1C32995122B9B0F00208ADC /* segmentedControlStop.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlStop.png; sourceTree = ""; }; + E1C32997122B9B1500208ADC /* segmentedControlSnooze.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlSnooze.png; sourceTree = ""; }; + E1C32A1D122CC6CF00208ADC /* SleepTimerSettingsView-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = "SleepTimerSettingsView-iPad.xib"; sourceTree = ""; }; + E1C3AC7C12400DED00697B56 /* clockView-iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "clockView-iPad.png"; sourceTree = ""; }; + E1C3AC811240105B00697B56 /* ClockView.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ClockView.png; sourceTree = ""; }; + E1C3ACC912408DB200697B56 /* numericBlueButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = numericBlueButton.png; sourceTree = ""; }; + E1C3ACD512408F9500697B56 /* numericRedButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = numericRedButton.png; sourceTree = ""; }; + E1C3ACF51240978A00697B56 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = ""; }; + E1C84244122874F70016D705 /* lightRow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = lightRow.png; sourceTree = ""; }; + E1C842B01228B61E0016D705 /* switch_on_lighter.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = switch_on_lighter.png; sourceTree = ""; }; + E1C842B41228B6C20016D705 /* switch_off_lighter.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = switch_off_lighter.png; sourceTree = ""; }; + E1C842C31228B8230016D705 /* switch_lighter.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = switch_lighter.png; sourceTree = ""; }; + E1C850DE1231C273004D23F6 /* segmentedControlPlaceSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlPlaceSelected.png; sourceTree = ""; }; + E1C850DF1231C273004D23F6 /* segmentedControlTimeDeselected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlTimeDeselected.png; sourceTree = ""; }; + E1C850E01231C273004D23F6 /* segmentedControlPlaceDeselected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlPlaceDeselected.png; sourceTree = ""; }; + E1C850E11231C273004D23F6 /* segmentedControlTimeSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = segmentedControlTimeSelected.png; sourceTree = ""; }; + E1CB6CFC101E8CB40008188B /* SCListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCListener.h; sourceTree = ""; }; + E1CB6CFD101E8CB40008188B /* SCListener.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCListener.m; sourceTree = ""; }; + E1CD26BD115A9CA600D26D79 /* SleepTimerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SleepTimerController.h; sourceTree = ""; }; + E1CD26BE115A9CA600D26D79 /* SleepTimerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SleepTimerController.m; sourceTree = ""; }; + E1D3AE1B10BC8937001F61ED /* ClockViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClockViewController.h; sourceTree = ""; }; + E1D3AE1C10BC8937001F61ED /* ClockViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClockViewController.m; sourceTree = ""; }; + E1D95FEF126FFBE90028142E /* info@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "info@2x.png"; sourceTree = ""; }; + E1DB6D37117F99720089CC1A /* BlackSegmentedControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlackSegmentedControl.h; sourceTree = ""; }; + E1DB6D38117F99720089CC1A /* BlackSegmentedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BlackSegmentedControl.m; sourceTree = ""; }; + E1E26CF510057ED000896840 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + E1EDCE571226F6AD005F3467 /* keypadBackground.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = keypadBackground.png; sourceTree = ""; }; + E1F36C39118FB38B001B31ED /* dynamite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = dynamite.png; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, + 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, + E11130790FE5925B0037335E /* MediaPlayer.framework in Frameworks */, + E1183DDF0FF846EC003850BF /* AudioToolbox.framework in Frameworks */, + E1183DE30FF84707003850BF /* CoreFoundation.framework in Frameworks */, + E1E26CF610057ED000896840 /* CoreGraphics.framework in Frameworks */, + E1A400CC1027CF4E00A5AB67 /* AVFoundation.framework in Frameworks */, + E10822A91075C60A0017B639 /* QuartzCore.framework in Frameworks */, + E11B79FD1170FB39008CFF9B /* MapKit.framework in Frameworks */, + E11B7BBB11715DD5008CFF9B /* CoreLocation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 080E96DDFE201D6D7F000001 /* Classes */ = { + isa = PBXGroup; + children = ( + E141442E11EEE1D600273935 /* NSLocale+Misc.h */, + E141442F11EEE1D600273935 /* NSLocale+Misc.m */, + E107C3E8115C9CA000BF4BCA /* Randomizer.h */, + E107C3E9115C9CA000BF4BCA /* Randomizer.m */, + E107C3D4115C9C5900BF4BCA /* TBFOceanWaveGenerator.h */, + E107C3D5115C9C5900BF4BCA /* TBFOceanWaveGenerator.m */, + E1CD26BD115A9CA600D26D79 /* SleepTimerController.h */, + E1CD26BE115A9CA600D26D79 /* SleepTimerController.m */, + E1CB6CFC101E8CB40008188B /* SCListener.h */, + E17B68BD111779E90036C941 /* CustomUISwitch.h */, + E17B68BE111779E90036C941 /* CustomUISwitch.m */, + E1CB6CFD101E8CB40008188B /* SCListener.m */, + 1D3623240D0F684500981E51 /* Sleep_Blaster_touchAppDelegate.h */, + 1D3623250D0F684500981E51 /* Sleep_Blaster_touchAppDelegate.m */, + E19D466B0FED61A600553EE2 /* Constants.h */, + E11A30DA106C410600BE7E70 /* AlarmController.h */, + E11A30DB106C410600BE7E70 /* AlarmController.m */, + E117E2BF10C39B5D006723EF /* ShadowedLabel.h */, + E117E2C010C39B5D006723EF /* ShadowedLabel.m */, + E1DB6D37117F99720089CC1A /* BlackSegmentedControl.h */, + E1DB6D38117F99720089CC1A /* BlackSegmentedControl.m */, + ); + path = Classes; + sourceTree = ""; + }; + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 1D6058910D05DD3D006BFB54 /* Sleep Blaster touch.app */, + ); + name = Products; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* Sleep Blaster touch */ = { + isa = PBXGroup; + children = ( + E11B7A3811711F75008CFF9B /* Map */, + E1329DA41090A8B000787D98 /* DeepSleepPreventer */, + E11A31AC106C629200BE7E70 /* View Controllers */, + E11A31AB106C628800BE7E70 /* Views */, + 29B97315FDCFA39411CA2CEA /* Other Sources */, + 080E96DDFE201D6D7F000001 /* Classes */, + 29B97317FDCFA39411CA2CEA /* Resources */, + E10FE239121ED54800904361 /* Resources-iPad */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + 19C28FACFE9D520D11CA2CBB /* Products */, + ); + name = "Sleep Blaster touch"; + sourceTree = ""; + }; + 29B97315FDCFA39411CA2CEA /* Other Sources */ = { + isa = PBXGroup; + children = ( + 28A0AB4B0D9B1048005BE974 /* Sleep_Blaster_touch_Prefix.pch */, + 29B97316FDCFA39411CA2CEA /* main.m */, + ); + name = "Other Sources"; + sourceTree = ""; + }; + 29B97317FDCFA39411CA2CEA /* Resources */ = { + isa = PBXGroup; + children = ( + E1D95FEF126FFBE90028142E /* info@2x.png */, + E19DFC11125D8646009763EA /* silent.mp3 */, + E19DFACB12512081009763EA /* beep.wav */, + E1C0E1E61240B3580074B386 /* Icon.png */, + E1C3ACF51240978A00697B56 /* Icon@2x.png */, + E1C3ACD512408F9500697B56 /* numericRedButton.png */, + E1C3ACC912408DB200697B56 /* numericBlueButton.png */, + E1C3AC811240105B00697B56 /* ClockView.png */, + E1C850DE1231C273004D23F6 /* segmentedControlPlaceSelected.png */, + E1C850DF1231C273004D23F6 /* segmentedControlTimeDeselected.png */, + E1C850E01231C273004D23F6 /* segmentedControlPlaceDeselected.png */, + E1C850E11231C273004D23F6 /* segmentedControlTimeSelected.png */, + E1C84244122874F70016D705 /* lightRow.png */, + E1882D8A122D8B4B000901AB /* segmentedControlMusicDeselected.png */, + E1882D84122D8B45000901AB /* segmentedControlOceanWavesDeselected.png */, + E1882D85122D8B45000901AB /* segmentedControlMusicSelected.png */, + E1882D86122D8B45000901AB /* segmentedControlOceanWavesSelected.png */, + E1EDCE571226F6AD005F3467 /* keypadBackground.png */, + E14143FC11EEDA9100273935 /* KeypadView.xib */, + E1F36C39118FB38B001B31ED /* dynamite.png */, + E1A8D2FC118A1C1000B53A6A /* alarmRingingBottomBar.png */, + E1A8D299118A074200B53A6A /* snoozeButton.png */, + E1A8D297118A072F00B53A6A /* alarmOffButton.png */, + E1A3294A1188D3C9006E9BAE /* findLine.png */, + E1A328D811889DAE006E9BAE /* currentLocationGlowing.png */, + E18756C21186A47B00656ADB /* currentLocation.png */, + E18756891186764900656ADB /* hourGlassIcon.png */, + E1875673118637E600656ADB /* clockIcon.png */, + E1875653118615E800656ADB /* redDrawButtonPressed.png */, + E187560A118574CF00656ADB /* redDrawButton.png */, + E12348871184CB7700820805 /* mapBottomBar.png */, + E11B79B61170F6DE008CFF9B /* MapView.xib */, + E19238721168854D0034780C /* stopSleepTimerButton.png */, + E192383F1165DBA90034780C /* NoArtwork.tif */, + E19237D7116496630034780C /* fastForward.png */, + E19237D91164969A0034780C /* rewind.png */, + E19237BA11648D9F0034780C /* translucentScreen.png */, + E10E526711626EBB006BD725 /* alarmMiniLCD.png */, + E10E4ED9116026A1006BD725 /* sleepTimerButton.png */, + E107C3D2115C9C3D00BF4BCA /* pinkNoise.m4a */, + E1A3C7D0115446DD00BFEEB6 /* numericRedButtonPressed.png */, + E1A3C7B91154465A00BFEEB6 /* numericBlueButtonPressed.png */, + E1A3C7B01154451500BFEEB6 /* numericButton.png */, + E1A3C7B11154451500BFEEB6 /* numericButtonPressed.png */, + E1B427A51135B18D0002AF2D /* AlarmSettingsView.xib */, + E17720871136CD44001FB7D7 /* VoiceSettingsView.xib */, + E1102C4B111369EE00CF462E /* SleepTimerSettingsView.xib */, + E11EE33610EB26A900342E69 /* info.png */, + E1A1487B10D4A3B900840EBA /* bell.png */, + E15428EC10D0B57A0042935C /* digital-7 (italic).ttf */, + E1136F1210BF63B100CB9E67 /* digital-7.ttf */, + E1329D1C108EF09700787D98 /* explosion.mp3 */, + E1973FE41037862E0093AB67 /* TimeBar.png */, + E1973FDE103783CD0093AB67 /* AlarmRingingView.xib */, + E1A400BA1027CDA200A5AB67 /* alarm.mp3 */, + 8D1107310486CEB800E47090 /* Sleep_Blaster_touch-Info.plist */, + E1266BE41225003F00B92121 /* MainWindow.xib */, + ); + name = Resources; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + E10822A81075C60A0017B639 /* QuartzCore.framework */, + E1A400CB1027CF4E00A5AB67 /* AVFoundation.framework */, + E1E26CF510057ED000896840 /* CoreGraphics.framework */, + E1183DE20FF84707003850BF /* CoreFoundation.framework */, + E1183DDE0FF846EC003850BF /* AudioToolbox.framework */, + E11130780FE5925B0037335E /* MediaPlayer.framework */, + 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, + 1D30AB110D05D00D00671497 /* Foundation.framework */, + E11B79FC1170FB39008CFF9B /* MapKit.framework */, + E11B7BBA11715DD5008CFF9B /* CoreLocation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + E10FE239121ED54800904361 /* Resources-iPad */ = { + isa = PBXGroup; + children = ( + E1C3AC7C12400DED00697B56 /* clockView-iPad.png */, + E11EA131123AF31D00BC86BA /* blueTrack.png */, + E11EA132123AF31D00BC86BA /* whiteSlide.png */, + E11EA133123AF31D00BC86BA /* whiteTrack.png */, + E1BEDF24123A28A6009BD347 /* blackGlass.png */, + E1882D8E122D8BC5000901AB /* lightRowTop.png */, + E1C32997122B9B1500208ADC /* segmentedControlSnooze.png */, + E1C32995122B9B0F00208ADC /* segmentedControlStop.png */, + E1C32989122B965900208ADC /* segmentedControlStopSelected.png */, + E1C32987122B965600208ADC /* segmentedControlSnoozeSelected.png */, + E1C32914122B474800208ADC /* lightTexturedBackground.png */, + E1C32900122B178200208ADC /* Icon-72.png */, + E1C327E1122A55BE00208ADC /* blackScreen.png */, + E1C327171229D12900208ADC /* disclosure-iPad.png */, + E1C326B91229B48200208ADC /* indicatorLightOn-iPad.png */, + E1C3269612298F0A00208ADC /* indicatorLightOff-iPad.png */, + E1C842C31228B8230016D705 /* switch_lighter.png */, + E1C842B41228B6C20016D705 /* switch_off_lighter.png */, + E1C842B01228B61E0016D705 /* switch_on_lighter.png */, + E1266BC21224FAC800B92121 /* MainWindow-iPad.xib */, + E1266AB81223AFF500B92121 /* bell-iPad.png */, + E1266B891224EEF500B92121 /* AlarmSettingsView-iPad.xib */, + E1C3292B122B4ABE00208ADC /* VoiceSettingsView-iPad.xib */, + E1C32A1D122CC6CF00208ADC /* SleepTimerSettingsView-iPad.xib */, + E1A84AEF124DE466008AA3D6 /* MapView-iPad.xib */, + ); + name = "Resources-iPad"; + sourceTree = ""; + }; + E11A31AB106C628800BE7E70 /* Views */ = { + isa = PBXGroup; + children = ( + E11EE29410E990C100342E69 /* ClockView.h */, + E11EE29510E990C100342E69 /* ClockView.m */, + E11B7B27117145AC008CFF9B /* MapLinesAnnotation.m */, + ); + name = Views; + sourceTree = ""; + }; + E11A31AC106C629200BE7E70 /* View Controllers */ = { + isa = PBXGroup; + children = ( + E1BEDDDD1239E99C009BD347 /* EmptyViewController.h */, + E1BEDDDE1239E99C009BD347 /* EmptyViewController.m */, + E14143FA11EEDA9100273935 /* KeypadViewController.h */, + E14143FB11EEDA9100273935 /* KeypadViewController.m */, + E1973FDC103783CD0093AB67 /* AlarmRingingViewController.h */, + E1973FDD103783CD0093AB67 /* AlarmRingingViewController.m */, + E111306E0FE591160037335E /* AlarmSettingsViewController.h */, + E111306F0FE591160037335E /* AlarmSettingsViewController.m */, + E17720851136CD44001FB7D7 /* VoiceSettingsViewController.h */, + E17720861136CD44001FB7D7 /* VoiceSettingsViewController.m */, + E1D3AE1B10BC8937001F61ED /* ClockViewController.h */, + E1D3AE1C10BC8937001F61ED /* ClockViewController.m */, + E1102C49111369EE00CF462E /* SleepTimerSettingsViewController.h */, + E1102C4A111369EE00CF462E /* SleepTimerSettingsViewController.m */, + ); + name = "View Controllers"; + sourceTree = ""; + }; + E11B7A3811711F75008CFF9B /* Map */ = { + isa = PBXGroup; + children = ( + E11B79B41170F6DE008CFF9B /* MapViewController.h */, + E11B79B51170F6DE008CFF9B /* MapViewController.m */, + E11B7A0C1170FFD6008CFF9B /* MapAnnotationView.h */, + E11B7A0D1170FFD6008CFF9B /* MapAnnotationView.m */, + E11B7B26117145AC008CFF9B /* MapLinesAnnotation.h */, + E11B7B5D11714FC5008CFF9B /* MapDrawingView.h */, + E11B7B5E11714FC5008CFF9B /* MapDrawingView.m */, + E10BCD481191429E0013C7BD /* MapDrawingViewController.h */, + E10BCD491191429E0013C7BD /* MapDrawingViewController.m */, + ); + name = Map; + sourceTree = ""; + }; + E1329DA41090A8B000787D98 /* DeepSleepPreventer */ = { + isa = PBXGroup; + children = ( + E1329DA81090A8CC00787D98 /* noSound.wav */, + E1329DAA1090A8FD00787D98 /* DeepSleepPreventer.h */, + E1329DAB1090A8FD00787D98 /* DeepSleepPreventer.m */, + ); + name = DeepSleepPreventer; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1D6058900D05DD3D006BFB54 /* Sleep Blaster touch */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Sleep Blaster touch" */; + buildPhases = ( + 1D60588D0D05DD3D006BFB54 /* Resources */, + 1D60588E0D05DD3D006BFB54 /* Sources */, + 1D60588F0D05DD3D006BFB54 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Sleep Blaster touch"; + productName = "Sleep Blaster touch"; + productReference = 1D6058910D05DD3D006BFB54 /* Sleep Blaster touch.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Sleep Blaster touch" */; + compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + en, + ); + mainGroup = 29B97314FDCFA39411CA2CEA /* Sleep Blaster touch */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1D6058900D05DD3D006BFB54 /* Sleep Blaster touch */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 1D60588D0D05DD3D006BFB54 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E1A400BB1027CDA200A5AB67 /* alarm.mp3 in Resources */, + E1973FE0103783CD0093AB67 /* AlarmRingingView.xib in Resources */, + E1973FE71037862E0093AB67 /* TimeBar.png in Resources */, + E1329D1D108EF09700787D98 /* explosion.mp3 in Resources */, + E1329DA91090A8CC00787D98 /* noSound.wav in Resources */, + E1136F1310BF63B100CB9E67 /* digital-7.ttf in Resources */, + E15428ED10D0B57A0042935C /* digital-7 (italic).ttf in Resources */, + E1A1487C10D4A3B900840EBA /* bell.png in Resources */, + E11EE33710EB26A900342E69 /* info.png in Resources */, + E1102C4D111369EE00CF462E /* SleepTimerSettingsView.xib in Resources */, + E1B427A61135B18D0002AF2D /* AlarmSettingsView.xib in Resources */, + E17720891136CD44001FB7D7 /* VoiceSettingsView.xib in Resources */, + E1A3C7B21154451500BFEEB6 /* numericButton.png in Resources */, + E1A3C7B31154451500BFEEB6 /* numericButtonPressed.png in Resources */, + E1A3C7BB1154465A00BFEEB6 /* numericBlueButtonPressed.png in Resources */, + E1A3C7D2115446DD00BFEEB6 /* numericRedButtonPressed.png in Resources */, + E107C3D3115C9C3D00BF4BCA /* pinkNoise.m4a in Resources */, + E10E4EDA116026A1006BD725 /* sleepTimerButton.png in Resources */, + E10E526811626EBB006BD725 /* alarmMiniLCD.png in Resources */, + E19237BB11648D9F0034780C /* translucentScreen.png in Resources */, + E19237D8116496630034780C /* fastForward.png in Resources */, + E19237DA1164969A0034780C /* rewind.png in Resources */, + E19238401165DBA90034780C /* NoArtwork.tif in Resources */, + E19238731168854D0034780C /* stopSleepTimerButton.png in Resources */, + E11B79B81170F6DE008CFF9B /* MapView.xib in Resources */, + E12348881184CB7700820805 /* mapBottomBar.png in Resources */, + E187560B118574CF00656ADB /* redDrawButton.png in Resources */, + E1875654118615E800656ADB /* redDrawButtonPressed.png in Resources */, + E1875674118637E600656ADB /* clockIcon.png in Resources */, + E187568A1186764900656ADB /* hourGlassIcon.png in Resources */, + E18756C31186A47B00656ADB /* currentLocation.png in Resources */, + E1A328D911889DAE006E9BAE /* currentLocationGlowing.png in Resources */, + E1A3294B1188D3C9006E9BAE /* findLine.png in Resources */, + E1A8D298118A072F00B53A6A /* alarmOffButton.png in Resources */, + E1A8D29A118A074200B53A6A /* snoozeButton.png in Resources */, + E1A8D2FD118A1C1000B53A6A /* alarmRingingBottomBar.png in Resources */, + E1F36C3A118FB38B001B31ED /* dynamite.png in Resources */, + E14143FE11EEDA9100273935 /* KeypadView.xib in Resources */, + E1266AB91223AFF500B92121 /* bell-iPad.png in Resources */, + E1266B8A1224EEF500B92121 /* AlarmSettingsView-iPad.xib in Resources */, + E1266BC31224FAC800B92121 /* MainWindow-iPad.xib in Resources */, + E1266BE51225003F00B92121 /* MainWindow.xib in Resources */, + E1EDCE581226F6AD005F3467 /* keypadBackground.png in Resources */, + E1C84245122874F70016D705 /* lightRow.png in Resources */, + E1C842B11228B61E0016D705 /* switch_on_lighter.png in Resources */, + E1C842B51228B6C20016D705 /* switch_off_lighter.png in Resources */, + E1C842C41228B8230016D705 /* switch_lighter.png in Resources */, + E1C3269712298F0A00208ADC /* indicatorLightOff-iPad.png in Resources */, + E1C326BA1229B48200208ADC /* indicatorLightOn-iPad.png in Resources */, + E1C327181229D12900208ADC /* disclosure-iPad.png in Resources */, + E1C327E2122A55BE00208ADC /* blackScreen.png in Resources */, + E1C32901122B178200208ADC /* Icon-72.png in Resources */, + E1C32915122B474800208ADC /* lightTexturedBackground.png in Resources */, + E1C3292C122B4ABE00208ADC /* VoiceSettingsView-iPad.xib in Resources */, + E1C32988122B965600208ADC /* segmentedControlSnoozeSelected.png in Resources */, + E1C3298A122B965900208ADC /* segmentedControlStopSelected.png in Resources */, + E1C32996122B9B0F00208ADC /* segmentedControlStop.png in Resources */, + E1C32998122B9B1500208ADC /* segmentedControlSnooze.png in Resources */, + E1C32A1E122CC6CF00208ADC /* SleepTimerSettingsView-iPad.xib in Resources */, + E1882D87122D8B45000901AB /* segmentedControlOceanWavesDeselected.png in Resources */, + E1882D88122D8B45000901AB /* segmentedControlMusicSelected.png in Resources */, + E1882D89122D8B45000901AB /* segmentedControlOceanWavesSelected.png in Resources */, + E1882D8B122D8B4B000901AB /* segmentedControlMusicDeselected.png in Resources */, + E1882D8F122D8BC5000901AB /* lightRowTop.png in Resources */, + E1C850E21231C273004D23F6 /* segmentedControlPlaceSelected.png in Resources */, + E1C850E31231C273004D23F6 /* segmentedControlTimeDeselected.png in Resources */, + E1C850E41231C273004D23F6 /* segmentedControlPlaceDeselected.png in Resources */, + E1C850E51231C273004D23F6 /* segmentedControlTimeSelected.png in Resources */, + E1BEDF25123A28A6009BD347 /* blackGlass.png in Resources */, + E11EA134123AF31D00BC86BA /* blueTrack.png in Resources */, + E11EA135123AF31D00BC86BA /* whiteSlide.png in Resources */, + E11EA136123AF31D00BC86BA /* whiteTrack.png in Resources */, + E1C3AC7D12400DED00697B56 /* clockView-iPad.png in Resources */, + E1C3AC821240105B00697B56 /* ClockView.png in Resources */, + E1C3ACCA12408DB200697B56 /* numericBlueButton.png in Resources */, + E1C3ACD612408F9500697B56 /* numericRedButton.png in Resources */, + E1C3ACF61240978A00697B56 /* Icon@2x.png in Resources */, + E1C0E1E71240B3580074B386 /* Icon.png in Resources */, + E1A84AF0124DE466008AA3D6 /* MapView-iPad.xib in Resources */, + E19DFACC12512081009763EA /* beep.wav in Resources */, + E19DFC12125D8646009763EA /* silent.mp3 in Resources */, + E1D95FF0126FFBE90028142E /* info@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1D60588E0D05DD3D006BFB54 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D60589B0D05DD56006BFB54 /* main.m in Sources */, + 1D3623260D0F684500981E51 /* Sleep_Blaster_touchAppDelegate.m in Sources */, + E11130700FE591160037335E /* AlarmSettingsViewController.m in Sources */, + E1CB6CFE101E8CB40008188B /* SCListener.m in Sources */, + E1973FDF103783CD0093AB67 /* AlarmRingingViewController.m in Sources */, + E11A30DC106C410600BE7E70 /* AlarmController.m in Sources */, + E1329DAC1090A8FD00787D98 /* DeepSleepPreventer.m in Sources */, + E1D3AE1E10BC8937001F61ED /* ClockViewController.m in Sources */, + E117E2C110C39B5D006723EF /* ShadowedLabel.m in Sources */, + E11EE29610E990C100342E69 /* ClockView.m in Sources */, + E1102C4C111369EE00CF462E /* SleepTimerSettingsViewController.m in Sources */, + E17B68BF111779E90036C941 /* CustomUISwitch.m in Sources */, + E17720881136CD44001FB7D7 /* VoiceSettingsViewController.m in Sources */, + E1CD26BF115A9CA600D26D79 /* SleepTimerController.m in Sources */, + E107C3D6115C9C5900BF4BCA /* TBFOceanWaveGenerator.m in Sources */, + E107C3EA115C9CA000BF4BCA /* Randomizer.m in Sources */, + E11B79B71170F6DE008CFF9B /* MapViewController.m in Sources */, + E11B7A0E1170FFD6008CFF9B /* MapAnnotationView.m in Sources */, + E11B7B28117145AC008CFF9B /* MapLinesAnnotation.m in Sources */, + E11B7B5F11714FC5008CFF9B /* MapDrawingView.m in Sources */, + E1DB6D39117F99720089CC1A /* BlackSegmentedControl.m in Sources */, + E10BCD4A1191429E0013C7BD /* MapDrawingViewController.m in Sources */, + E14143FD11EEDA9100273935 /* KeypadViewController.m in Sources */, + E141443011EEE1D600273935 /* NSLocale+Misc.m in Sources */, + E1BEDDDF1239E99C009BD347 /* EmptyViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1D6058940D05DD3E006BFB54 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CODE_SIGN_ENTITLEMENTS = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Sleep_Blaster_touch_Prefix.pch; + INFOPLIST_FILE = "Sleep_Blaster_touch-Info.plist"; + PRODUCT_NAME = "Sleep Blaster touch"; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; + SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 1D6058950D05DD3E006BFB54 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CODE_SIGN_ENTITLEMENTS = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + COPY_PHASE_STRIP = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Sleep_Blaster_touch_Prefix.pch; + INFOPLIST_FILE = "Sleep_Blaster_touch-Info.plist"; + PRODUCT_NAME = "Sleep Blaster touch"; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; + SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CODE_SIGN_ENTITLEMENTS = ""; + CODE_SIGN_IDENTITY = "iPhone Distribution"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + PROVISIONING_PROFILE = ""; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; + SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CODE_SIGN_ENTITLEMENTS = ""; + CODE_SIGN_IDENTITY = "iPhone Distribution"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + PROVISIONING_PROFILE = ""; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; + SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + E1BE51CA1260014A00FEA0B4 /* Ad-hoc */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CODE_SIGN_ENTITLEMENTS = ""; + CODE_SIGN_IDENTITY = "iPhone Distribution"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + PROVISIONING_PROFILE = ""; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; + SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = "Ad-hoc"; + }; + E1BE51CB1260014A00FEA0B4 /* Ad-hoc */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CODE_SIGN_ENTITLEMENTS = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Sleep_Blaster_touch_Prefix.pch; + INFOPLIST_FILE = "Sleep_Blaster_touch-Info.plist"; + PRODUCT_NAME = "Sleep Blaster touch"; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; + SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = "Ad-hoc"; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Sleep Blaster touch" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1D6058940D05DD3E006BFB54 /* Debug */, + E1BE51CB1260014A00FEA0B4 /* Ad-hoc */, + 1D6058950D05DD3E006BFB54 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Sleep Blaster touch" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + E1BE51CA1260014A00FEA0B4 /* Ad-hoc */, + C01FCF5008A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/Sleep Blaster touch.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Sleep Blaster touch.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ca37190 --- /dev/null +++ b/Sleep Blaster touch.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,6 @@ + + + + + diff --git a/Sleep Blaster touch.xcodeproj/project.xcworkspace/xcuserdata/eamonford.xcuserdatad/UserInterfaceState.xcuserstate b/Sleep Blaster touch.xcodeproj/project.xcworkspace/xcuserdata/eamonford.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..71a1ecd Binary files /dev/null and b/Sleep Blaster touch.xcodeproj/project.xcworkspace/xcuserdata/eamonford.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Sleep Blaster touch.xcodeproj/project.xcworkspace/xcuserdata/eamonford.xcuserdatad/WorkspaceState.xcuserstate b/Sleep Blaster touch.xcodeproj/project.xcworkspace/xcuserdata/eamonford.xcuserdatad/WorkspaceState.xcuserstate new file mode 100644 index 0000000..7355f9c --- /dev/null +++ b/Sleep Blaster touch.xcodeproj/project.xcworkspace/xcuserdata/eamonford.xcuserdatad/WorkspaceState.xcuserstate @@ -0,0 +1,2697 @@ + + + + + $archiver + NSKeyedArchiver + $objects + + $null + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 2 + + + CF$UID + 3 + + + NS.objects + + + CF$UID + 4 + + + CF$UID + 181 + + + + IDEWorkspaceWindowController_0 + IDEWorkspaceDocument + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 5 + + + CF$UID + 6 + + + CF$UID + 7 + + + CF$UID + 8 + + + CF$UID + 9 + + + NS.objects + + + CF$UID + 10 + + + CF$UID + 12 + + + CF$UID + 9 + + + CF$UID + 13 + + + CF$UID + 14 + + + + IDEOrderedWorkspaceTabControllers + IDEUserWantsMiniDebuggingConsole + IDEActiveWorkspaceTabController + IDEWindowFrame + IDEWorkspaceTabController_0 + + $class + + CF$UID + 11 + + NS.objects + + + CF$UID + 9 + + + + + $classes + + NSArray + NSObject + + $classname + NSArray + + + {{1, 4}, {1280, 774}} + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 15 + + + CF$UID + 16 + + + CF$UID + 17 + + + CF$UID + 18 + + + CF$UID + 19 + + + CF$UID + 20 + + + CF$UID + 21 + + + NS.objects + + + CF$UID + 22 + + + CF$UID + 23 + + + CF$UID + 24 + + + CF$UID + 37 + + + CF$UID + 109 + + + CF$UID + 12 + + + CF$UID + 118 + + + + IDETabLabel + IDEShowNavigator + IDEWorkspaceTabControllerUtilityAreaSplitView + IDENavigatorArea + IDEWorkspaceTabControllerDesignAreaSplitView + IDEShowUtilities + IDEEditorArea + mach_msg_trap_disassembly_B4FAF615-4B51-4AC3-A11E-B30AEDF9CB7C.nasm + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 25 + + + NS.objects + + + CF$UID + 26 + + + + DVTSplitViewItems + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 27 + + + CF$UID + 33 + + + + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 28 + + + CF$UID + 29 + + + NS.objects + + + CF$UID + 30 + + + CF$UID + 31 + + + + DVTIdentifier + DVTViewMagnitude + + 337 + + $classes + + NSDictionary + NSObject + + $classname + NSDictionary + + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 28 + + + CF$UID + 29 + + + NS.objects + + + CF$UID + 30 + + + CF$UID + 34 + + + + 364 + + $classes + + NSMutableArray + NSArray + NSObject + + $classname + NSMutableArray + + + $classes + + NSMutableDictionary + NSDictionary + NSObject + + $classname + NSMutableDictionary + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 38 + + + CF$UID + 39 + + + CF$UID + 40 + + + CF$UID + 41 + + + CF$UID + 42 + + + CF$UID + 43 + + + CF$UID + 44 + + + CF$UID + 45 + + + NS.objects + + + CF$UID + 46 + + + CF$UID + 47 + + + CF$UID + 53 + + + CF$UID + 44 + + + CF$UID + 67 + + + CF$UID + 83 + + + CF$UID + 84 + + + CF$UID + 102 + + + + Xcode.IDEKit.Navigator.Symbol + Xcode.DebuggerKit.ThreadsStacksNavigator + Xcode.IDEKit.Navigator.BatchFind + SelectedNavigator + Xcode.IDEKit.Navigator.Issues + Xcode.IDEKit.Navigator.Breakpoints + Xcode.IDEKit.Navigator.Structure + Xcode.IDEKit.Navigator.Logs + + $class + + CF$UID + 36 + + NS.keys + + NS.objects + + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 48 + + + CF$UID + 49 + + + CF$UID + 50 + + + NS.objects + + + CF$UID + 51 + + + CF$UID + 52 + + + CF$UID + 12 + + + + IDEStackCompressionValue + IDEThreadsOrQueuesMode + IDEHideAncestorIfAllFramesHaveNoSymbols + 2 + 0 + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 54 + + + CF$UID + 55 + + + CF$UID + 56 + + + CF$UID + 57 + + + CF$UID + 58 + + + CF$UID + 59 + + + CF$UID + 60 + + + NS.objects + + + CF$UID + 12 + + + CF$UID + 61 + + + CF$UID + 12 + + + CF$UID + 62 + + + CF$UID + 64 + + + CF$UID + 52 + + + CF$UID + 65 + + + + IDEBatchFindNavigatorShowsOptions + IDEBatchFindNavigatorReplaceString + IDEBatchFindNavigatorShowsReplacePreview + IDEBatchFindNavigatorSelectedRowIndexes + IDEBatchFindNavigatorFindString + IDEBatchFindNavigatorFindMode + IDEBatchFindNavigatorCollapsedGroups + + + $class + + CF$UID + 63 + + NSRangeCount + 0 + + + $classes + + NSIndexSet + NSObject + + $classname + NSIndexSet + + iphone + + $class + + CF$UID + 66 + + NSRangeCount + 0 + + + $classes + + NSMutableIndexSet + NSIndexSet + NSObject + + $classname + NSMutableIndexSet + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 68 + + + CF$UID + 69 + + + CF$UID + 70 + + + CF$UID + 71 + + + CF$UID + 72 + + + CF$UID + 73 + + + CF$UID + 74 + + + CF$UID + 75 + + + NS.objects + + + CF$UID + 12 + + + CF$UID + 76 + + + CF$UID + 77 + + + CF$UID + 79 + + + CF$UID + 12 + + + CF$UID + 80 + + + CF$UID + 81 + + + CF$UID + 82 + + + + IDEErrorFilteringEnabled + IDEVisibleRect + IDECollapsedFiles + IDEExpandedIssues + IDEShowsByType + IDESelectedNavigables + IDECollapsedTypes + IDECollapsedGroups + {{0, 0}, {244, 635}} + + $class + + CF$UID + 78 + + NS.objects + + + + $classes + + NSMutableSet + NSSet + NSObject + + $classname + NSMutableSet + + + $class + + CF$UID + 78 + + NS.objects + + + + $class + + CF$UID + 78 + + NS.objects + + + + $class + + CF$UID + 78 + + NS.objects + + + + $class + + CF$UID + 78 + + NS.objects + + + + $class + + CF$UID + 36 + + NS.keys + + NS.objects + + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 85 + + + CF$UID + 86 + + + CF$UID + 87 + + + CF$UID + 88 + + + CF$UID + 89 + + + CF$UID + 90 + + + NS.objects + + + CF$UID + 12 + + + CF$UID + 91 + + + CF$UID + 98 + + + CF$UID + 12 + + + CF$UID + 101 + + + CF$UID + 12 + + + + IDEUnsavedDocumentFilteringEnabled + IDEExpandedItems + IDESelectedObjects + IDESCMStatusFilteringEnabled + IDEVisibleRect + IDERecentDocumentFilteringEnabled + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 92 + + + CF$UID + 94 + + + CF$UID + 96 + + + + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 93 + + + + Sleep Blaster touch + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 93 + + + CF$UID + 95 + + + + Map + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 93 + + + CF$UID + 97 + + + + Resources + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 99 + + + + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 93 + + + CF$UID + 95 + + + CF$UID + 100 + + + + MapViewController.m + {{0, 0}, {244, 657}} + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 103 + + + CF$UID + 104 + + + CF$UID + 105 + + + NS.objects + + + CF$UID + 106 + + + CF$UID + 107 + + + CF$UID + 108 + + + + IDESelectedObjects + IDEVisibleRect + IDEExpandedItems + + $class + + CF$UID + 35 + + NS.objects + + + {{0, 0}, {259, 679}} + + $class + + CF$UID + 35 + + NS.objects + + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 25 + + + NS.objects + + + CF$UID + 110 + + + + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 111 + + + CF$UID + 113 + + + CF$UID + 115 + + + + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 28 + + + CF$UID + 29 + + + NS.objects + + + CF$UID + 18 + + + CF$UID + 112 + + + + 260 + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 28 + + + CF$UID + 29 + + + NS.objects + + + CF$UID + 21 + + + CF$UID + 114 + + + + 1020 + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 28 + + + CF$UID + 29 + + + NS.objects + + + CF$UID + 116 + + + CF$UID + 117 + + + + IDEUtilitiesArea + 260 + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 119 + + + CF$UID + 120 + + + CF$UID + 121 + + + CF$UID + 122 + + + CF$UID + 123 + + + CF$UID + 124 + + + CF$UID + 125 + + + NS.objects + + + CF$UID + 126 + + + CF$UID + 155 + + + CF$UID + 52 + + + CF$UID + 165 + + + CF$UID + 167 + + + CF$UID + 174 + + + CF$UID + 23 + + + + IDEEditorMode_Standard + IDEEDitorArea_DebugArea + EditorMode + IDEEditorMode_Version + IDEEditorArea_DebuggerSplitView + IDEEditorMode_Genius + ShowDebuggerArea + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 127 + + + NS.objects + + + CF$UID + 128 + + + + EditorStates + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 127 + + + CF$UID + 129 + + + NS.objects + + + CF$UID + 130 + + + CF$UID + 52 + + + + SelectedEditorState + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 131 + + + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 132 + + + CF$UID + 133 + + + CF$UID + 134 + + + CF$UID + 135 + + + CF$UID + 136 + + + CF$UID + 137 + + + NS.objects + + + CF$UID + 138 + + + CF$UID + 145 + + + CF$UID + 149 + + + CF$UID + 152 + + + CF$UID + 153 + + + CF$UID + 154 + + + + EditorState + ArchivableRepresentation + DocumentURL + FileDataType + DocumentExtensionIdentifier + HistoryMenuDescription + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 139 + + + CF$UID + 140 + + + CF$UID + 141 + + + NS.objects + + + CF$UID + 142 + + + CF$UID + 143 + + + CF$UID + 144 + + + + PrimaryDocumentSelectedCharacterRange + PrimaryDocumentVisibleCharacterRange + PrimaryDocumentTimestamp + {158, 0} + {0, 158} + 303369800.54997402 + + $class + + CF$UID + 148 + + DocumentLocation + + CF$UID + 147 + + DomainIdentifier + + CF$UID + 0 + + IdentifierPath + + CF$UID + 146 + + + + $class + + CF$UID + 11 + + NS.objects + + + $null + + $classes + + IDENavigableItemArchivableRepresentation + NSObject + + $classname + IDENavigableItemArchivableRepresentation + + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 150 + + + file://localhost/var/folders/Yt/YtVjtkN8HrWBO6C1KLlkwU+++TI/-Tmp-/mach_msg_trap_disassembly_B4FAF615-4B51-4AC3-A11E-B30AEDF9CB7C.nasm + + $classes + + NSURL + NSObject + + $classname + NSURL + + public.nasm-assembly-source + Xcode.IDEKit.EditorDocument.SourceCode + mach_msg_trap_disassembly_B4FAF615-4B51-4AC3-A11E-B30AEDF9CB7C.nasm + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 156 + + + CF$UID + 157 + + + CF$UID + 158 + + + CF$UID + 159 + + + NS.objects + + + CF$UID + 160 + + + CF$UID + 161 + + + CF$UID + 160 + + + CF$UID + 163 + + + + LayoutFocusMode + console + LayoutMode + variables + 1 + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 162 + + + NS.objects + + + CF$UID + 52 + + + + ConsoleFilterMode + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 164 + + + NS.objects + + + CF$UID + 51 + + + + DBGVariablesViewFilterMode + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 166 + + + NS.objects + + + CF$UID + 52 + + + + VersionsEditorSubmode + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 25 + + + NS.objects + + + CF$UID + 168 + + + + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 169 + + + CF$UID + 171 + + + + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 28 + + + CF$UID + 29 + + + NS.objects + + + CF$UID + 30 + + + CF$UID + 170 + + + + 553 + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 28 + + + CF$UID + 29 + + + NS.objects + + + CF$UID + 172 + + + CF$UID + 173 + + + + IDEDebuggerArea + 148 + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 175 + + + CF$UID + 176 + + + NS.objects + + + CF$UID + 12 + + + CF$UID + 177 + + + + ManualMode + GeniusLayout + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 178 + + + CF$UID + 179 + + + NS.objects + + + CF$UID + 12 + + + CF$UID + 180 + + + + SplitsVertical + SplitPosition + 0.5 + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 182 + + + CF$UID + 183 + + + CF$UID + 184 + + + CF$UID + 185 + + + CF$UID + 186 + + + CF$UID + 187 + + + CF$UID + 188 + + + CF$UID + 189 + + + NS.objects + + + CF$UID + 12 + + + CF$UID + 190 + + + CF$UID + 251 + + + CF$UID + 254 + + + CF$UID + 259 + + + CF$UID + 260 + + + CF$UID + 12 + + + CF$UID + 12 + + + + BreakpointsActivated + DefaultEditorStatesForURLs + ActiveScheme + ActiveRunDestination + DocumentWindows + RecentEditorDocumentURLs + AppFocusInMiniDebugging + DebuggingWindowsLayerMode + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 191 + + + CF$UID + 192 + + + CF$UID + 193 + + + CF$UID + 194 + + + NS.objects + + + CF$UID + 195 + + + CF$UID + 221 + + + CF$UID + 234 + + + CF$UID + 244 + + + + Xcode.Xcode3ProjectSupport.EditorDocument.Xcode3Project + Xcode.IDEKit.EditorDocument.SourceCode + IDEQuickLookEditor.Editor + Xcode.IDEKit.CocoaTouchIntegration.EditorDocument.CocoaTouch + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 196 + + + NS.objects + + + CF$UID + 199 + + + + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 197 + + + + $class + + CF$UID + 198 + + NS.string + file://localhost/Users/eamonford/Desktop/Sleep%20Blaster%20touch/Sleep%20Blaster%20touch.xcodeproj/ + + + $classes + + NSMutableString + NSString + NSObject + + $classname + NSMutableString + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 200 + + + CF$UID + 201 + + + NS.objects + + + CF$UID + 202 + + + CF$UID + 212 + + + + SelectedDocumentLocations + Xcode3ProjectEditor.sourceList.splitview + + $class + + CF$UID + 11 + + NS.objects + + + CF$UID + 203 + + + + + $class + + CF$UID + 211 + + documentURL + + CF$UID + 204 + + selection + + CF$UID + 206 + + timestamp + + CF$UID + 205 + + + file://localhost/Users/eamonford/Desktop/Sleep%20Blaster%20touch/Sleep%20Blaster%20touch.xcodeproj/ + 303369560.38533902 + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 207 + + + CF$UID + 208 + + + NS.objects + + + CF$UID + 209 + + + CF$UID + 210 + + + + Project + Editor + Sleep Blaster touch + Xcode3ProjectInfoEditor + + $classes + + Xcode3ProjectDocumentLocation + DVTDocumentLocation + NSObject + + $classname + Xcode3ProjectDocumentLocation + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 213 + + + NS.objects + + + CF$UID + 214 + + + + DVTSplitViewItems + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 215 + + + CF$UID + 219 + + + + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 216 + + + CF$UID + 217 + + + NS.objects + + + CF$UID + 61 + + + CF$UID + 218 + + + + DVTIdentifier + DVTViewMagnitude + 162 + + $class + + CF$UID + 32 + + NS.keys + + + CF$UID + 216 + + + CF$UID + 217 + + + NS.objects + + + CF$UID + 61 + + + CF$UID + 220 + + + + 858 + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 222 + + + CF$UID + 224 + + + NS.objects + + + CF$UID + 226 + + + CF$UID + 230 + + + + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 223 + + + + $class + + CF$UID + 198 + + NS.string + file://localhost/var/folders/Yt/YtVjtkN8HrWBO6C1KLlkwU+++TI/-Tmp-/read$UNIX2003_disassembly_575BC0C0-B103-4BB1-A8D4-D1871463A6D7.nasm + + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 225 + + + + $class + + CF$UID + 198 + + NS.string + file://localhost/Users/eamonford/Desktop/Sleep%20Blaster%20touch/MapViewController.m + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 139 + + + CF$UID + 140 + + + CF$UID + 141 + + + NS.objects + + + CF$UID + 227 + + + CF$UID + 228 + + + CF$UID + 229 + + + + {0, 0} + {0, 387} + 303369795.88666701 + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 139 + + + CF$UID + 141 + + + CF$UID + 140 + + + NS.objects + + + CF$UID + 231 + + + CF$UID + 232 + + + CF$UID + 233 + + + + {298, 0} + 303369783.05506802 + {0, 1040} + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 235 + + + NS.objects + + + CF$UID + 237 + + + + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 236 + + + + $class + + CF$UID + 198 + + NS.string + file://localhost/Users/eamonford/Desktop/Sleep%20Blaster%20touch/launchImage.png + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 238 + + + NS.objects + + + CF$UID + 239 + + + + SelectedDocumentLocations + + $class + + CF$UID + 11 + + NS.objects + + + CF$UID + 240 + + + + + $class + + CF$UID + 243 + + IDEQuickLookPageNumber + + CF$UID + 52 + + documentURL + + CF$UID + 241 + + timestamp + + CF$UID + 242 + + + file://localhost/Users/eamonford/Desktop/Sleep%20Blaster%20touch/launchImage.png + 303369672.57103801 + + $classes + + IDEQuickLookDocumentLocation + DVTDocumentLocation + NSObject + + $classname + IDEQuickLookDocumentLocation + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 245 + + + NS.objects + + + CF$UID + 247 + + + + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 246 + + + + $class + + CF$UID + 198 + + NS.string + file://localhost/Users/eamonford/Desktop/Sleep%20Blaster%20touch/KeypadView.xib + + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 248 + + + NS.objects + + + CF$UID + 249 + + + + ObjectIDs + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 250 + + + + 4 + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 252 + + + NS.objects + + + CF$UID + 253 + + + + IDENameString + Sleep Blaster touch + + $class + + CF$UID + 36 + + NS.keys + + + CF$UID + 255 + + + CF$UID + 256 + + + NS.objects + + + CF$UID + 257 + + + CF$UID + 258 + + + + IDEDeviceLocation + IDEDeviceArchitecture + dvtdevice-iphonesimulator:/Xcode4/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk-iPad + i386 + + $class + + CF$UID + 35 + + NS.objects + + + + $class + + CF$UID + 35 + + NS.objects + + + CF$UID + 261 + + + CF$UID + 262 + + + CF$UID + 264 + + + CF$UID + 266 + + + CF$UID + 267 + + + CF$UID + 269 + + + + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 150 + + + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 263 + + + file://localhost/var/folders/Yt/YtVjtkN8HrWBO6C1KLlkwU+++TI/-Tmp-/read$UNIX2003_disassembly_575BC0C0-B103-4BB1-A8D4-D1871463A6D7.nasm + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 265 + + + file://localhost/Users/eamonford/Desktop/Sleep%20Blaster%20touch/MapViewController.m + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 241 + + + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 268 + + + file://localhost/Users/eamonford/Desktop/Sleep%20Blaster%20touch/KeypadView.xib + + $class + + CF$UID + 151 + + NS.base + + CF$UID + 0 + + NS.relative + + CF$UID + 204 + + + + $top + + State + + CF$UID + 1 + + + $version + 100000 + + diff --git a/Sleep Blaster touch.xcodeproj/xcuserdata/eamonford.xcuserdatad/xcschemes/Sleep Blaster touch.xcscheme b/Sleep Blaster touch.xcodeproj/xcuserdata/eamonford.xcuserdatad/xcschemes/Sleep Blaster touch.xcscheme new file mode 100644 index 0000000..3e8bfb4 --- /dev/null +++ b/Sleep Blaster touch.xcodeproj/xcuserdata/eamonford.xcuserdatad/xcschemes/Sleep Blaster touch.xcscheme @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sleep Blaster touch.xcodeproj/xcuserdata/eamonford.xcuserdatad/xcschemes/xcschememanagement.plist b/Sleep Blaster touch.xcodeproj/xcuserdata/eamonford.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..edc8fbe --- /dev/null +++ b/Sleep Blaster touch.xcodeproj/xcuserdata/eamonford.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,19 @@ + + + + + SchemeUserState + + Sleep Blaster touch.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + Sleep Blaster touch.app + + + + diff --git a/SleepTimerSettingsView-iPad.xib b/SleepTimerSettingsView-iPad.xib new file mode 100644 index 0000000..33464cd --- /dev/null +++ b/SleepTimerSettingsView-iPad.xib @@ -0,0 +1,1501 @@ + + + + 1024 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 123 + + + YES + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + 301 + + YES + + + 256 + {{0, 42}, {320, 320}} + + + NO + YES + 4 + YES + IBIPadFramework + + + + 292 + {{0, 42}, {320, 367}} + + + NO + YES + 4 + YES + IBIPadFramework + + NSImage + translucentScreen.png + + + + + 256 + {{0, 361}, {320, 119}} + + + NO + YES + 4 + YES + IBIPadFramework + + NSImage + blackGlass.png + + + + + 292 + {{20, 274}, {280, 22}} + + + NO + YES + NO + IBIPadFramework + Song title + + 1 + MSAxIDEAA + + 1 + + + + + 3 + MAA + + 1 + 10 + 1 + + + + 292 + {{20, 294}, {280, 22}} + + + NO + YES + NO + IBIPadFramework + Song artist + + 1 + MSAxIDEAA + + + + + 1 + 10 + 1 + + + + 292 + {{30, 373}, {50, 50}} + + + NO + NO + IBIPadFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + + 3 + MQA + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + 3 + MC41AA + + + NSImage + rewind.png + + + + + 292 + {{240, 373}, {50, 50}} + + + NO + NO + IBIPadFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + NSImage + fastForward.png + + + + + 292 + {{140, 377}, {40, 42}} + + + NO + NO + IBIPadFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + NSImage + stopSleepTimerButton.png + + + + + 292 + {{35, 79}, {250, 75}} + + + NO + YES + NO + IBIPadFramework + 00:00:00 + + Helvetica + 64 + 16 + + + 1 + MSAxIDEAA + + + + + 1 + 10 + 1 + + + + 292 + {{28, 444}, {264, 23}} + + + NO + IBIPadFramework + 0 + 0 + 0.5 + + + {320, 480} + + + + 1 + MCAwIDAAA + + NO + IBIPadFramework + + + + 292 + + YES + + + 292 + {{0, 44}, {320, 216}} + + NO + YES + YES + IBIPadFramework + 0 + 0 + 3 + + en_US + + + America/Los_Angeles + + VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ +y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ +5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g +8n/BkPNvwKD0X6OQ9U+ioPY/hZD3L4Sg+CiiEPkPZqD6CIQQ+viDIPvoZhD82GUg/chIEP64RyD/qCoQ +AJgpIAGIDBACeAsgA3EokARhJ6AFUQqQBkEJoAcw7JAHjUOgCRDOkAmtvyAK8LCQC+CvoAzZzRANwJGg +DrmvEA+priAQmZEQEYmQIBJ5cxATaXIgFFlVEBVJVCAWOTcQFyk2IBgiU5AZCRggGgI1kBryNKAb4heQ +HNIWoB3B+ZAesfigH6HbkCB2KyAhgb2QIlYNICNq2hAkNe8gJUq8ECYV0SAnKp4QJ/7toCkKgBAp3s+g +KupiECu+saAs036QLZ6ToC6zYJAvfnWgMJNCkDFnkiAycySQM0d0IDRTBpA1J1YgNjLokDcHOCA4HAUQ +OOcaIDn75xA6xvwgO9vJEDywGKA9u6sQPo/6oD+bjRBAb9ygQYSpkEJPvqBDZIuQRC+goEVEbZBF89Mg +Ry2KEEfTtSBJDWwQSbOXIErtThBLnLOgTNZqkE18laBOtkyQT1x3oFCWLpBRPFmgUnYQkFMcO6BUVfKQ +VPwdoFY11JBW5TogWB7xEFjFHCBZ/tMQWqT+IFvetRBchOAgXb6XEF5kwiBfnnkQYE3eoGGHlZBiLcCg +Y2d3kGQNoqBlR1mQZe2EoGcnO5BnzWagaQcdkGmtSKBq5v+Qa5ZlIGzQHBBtdkcgbq/+EG9WKSBwj+AQ +cTYLIHJvwhBzFe0gdE+kEHT/CaB2OMCQdt7roHgYopB4vs2gefiEkHqer6B72GaQfH6RoH24SJB+XnOg +f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA + + + + 286485008.01363301 + + 1 + + + + 290 + {320, 44} + + NO + NO + IBIPadFramework + 2 + + YES + + + + + Done + IBIPadFramework + 1 + + + IBIPadFramework + + + + + {320, 260} + + 3 + MSAwAA + + 2 + + + NO + NO + + 3 + + IBIPadFramework + + + + 301 + + YES + + + 301 + {320, 480} + + NO + YES + YES + IBIPadFramework + + NSImage + lightTexturedBackground.png + + + + + 292 + {{0, 135}, {320, 195}} + + + NO + YES + NO + IBIPadFramework + NO + NO + 0 + YES + 44 + 22 + 22 + + + + 292 + {{0, 20}, {320, 45}} + + NO + NO + IBIPadFramework + 0 + 0 + + Helvetica-Bold + 14 + 16 + + {0, -1} + Start Sleep Timer + + + + 1 + MC4yNTAzMDg4NDAyIDAuMzk3OTU5MTgzNyAwLjI3NDk5MTY5NAA + + + NSImage + sleepTimerButton.png + + + + + 292 + {{20, 338}, {280, 71}} + + NO + YES + NO + IBIPadFramework + When the sleep timer is done, it will automatically fade out the volume to avoid stopping abruptly. + + Helvetica + 15 + 16 + + + 1 + MCAwIDAAA + + + + + {0, 1} + 1 + NO + 10 + 6 + 1 + + + + 292 + {{0, 76}, {160, 40}} + + NO + 2000 + IBIPadFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + NSImage + segmentedControlMusicSelected.png + + + + + 292 + {{160, 76}, {160, 40}} + + NO + 2001 + IBIPadFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + NSImage + segmentedControlOceanWavesSelected.png + + + + {320, 480} + + IBIPadFramework + + + + + YES + + + artworkContainerView + + + + 30 + + + + datePickerContainerView + + + + 31 + + + + songLabel + + + + 32 + + + + artistLabel + + + + 33 + + + + previousButton + + + + 34 + + + + nextButton + + + + 35 + + + + timerTableView + + + + 62 + + + + view + + + + 63 + + + + dataSource + + + + 64 + + + + delegate + + + + 65 + + + + buttonSegmentTapped: + + + 7 + + 68 + + + + buttonSegmentTapped: + + + 7 + + 69 + + + + datePicker + + + + 71 + + + + nextSong: + + + 7 + + 72 + + + + previousSong: + + + 7 + + 73 + + + + toggleSleepTimer: + + + 7 + + 74 + + + + toggleSleepTimer: + + + 7 + + 75 + + + + setSleepTimerTime: + + + 13 + + 76 + + + + toggleDatePicker: + + + + 77 + + + + timerLabel + + + + 79 + + + + button + + + + 80 + + + + artworkImageView + + + + 81 + + + + volumeSlider + + + + 84 + + + + volumeSliderMoved: + + + 13 + + 85 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 14 + + + YES + + + + + + + + + + + + + Artwork Container + + + 15 + + + + + 16 + + + + + 17 + + + + + 18 + + + + + 19 + + + + + 20 + + + + + 21 + + + + + 22 + + + + + 23 + + + + + 24 + + + YES + + + + + Date Picker Container + + + 25 + + + + + 26 + + + YES + + + + + + 27 + + + YES + + + + + + 28 + + + + + 53 + + + YES + + + + + + + + + + + 56 + + + + + 58 + + + + + 59 + + + + + 60 + + + + + 57 + + + + + 54 + + + + + 83 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 14.IBEditorWindowLastContentRect + 14.IBPluginDependency + 15.IBPluginDependency + 16.IBPluginDependency + 17.IBPluginDependency + 18.IBPluginDependency + 19.IBPluginDependency + 20.IBPluginDependency + 24.IBEditorWindowLastContentRect + 24.IBPluginDependency + 25.IBPluginDependency + 26.IBPluginDependency + 27.IBPluginDependency + 28.IBPluginDependency + 53.IBEditorWindowLastContentRect + 53.IBPluginDependency + 56.IBPluginDependency + 57.IBPluginDependency + 58.IBPluginDependency + 59.IBPluginDependency + 60.IBPluginDependency + 83.IBPluginDependency + 83.IBViewBoundsToFrameTransform + + + YES + SleepTimerSettingsViewController + UIResponder + {{621, 186}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + {{565, 80}, {320, 260}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + {{300, 276}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + AUHgAABD3gAAA + + + + + YES + + + YES + + + + + YES + + + YES + + + + 85 + + + + YES + + SleepTimerSettingsViewController + UIViewController + + YES + + YES + buttonSegmentTapped: + chooseMusic: + doneButtonTapped: + nextSong: + previousSong: + setSleepTimerTime: + toggleDatePicker: + toggleSleepTimer: + volumeSliderMoved: + + + YES + UIButton + id + id + id + id + id + id + id + UISlider + + + + YES + + YES + buttonSegmentTapped: + chooseMusic: + doneButtonTapped: + nextSong: + previousSong: + setSleepTimerTime: + toggleDatePicker: + toggleSleepTimer: + volumeSliderMoved: + + + YES + + buttonSegmentTapped: + UIButton + + + chooseMusic: + id + + + doneButtonTapped: + id + + + nextSong: + id + + + previousSong: + id + + + setSleepTimerTime: + id + + + toggleDatePicker: + id + + + toggleSleepTimer: + id + + + volumeSliderMoved: + UISlider + + + + + YES + + YES + artistLabel + artworkContainerView + artworkImageView + button + datePicker + datePickerContainerView + musicTableView + navigationBar + nextButton + previousButton + segmentedControl + songLabel + timerLabel + timerTableView + volumeSlider + + + YES + UILabel + UIView + UIImageView + UIButton + UIDatePicker + UIView + UITableView + UINavigationBar + UIButton + UIButton + UISegmentedControl + UILabel + UILabel + UITableView + UISlider + + + + YES + + YES + artistLabel + artworkContainerView + artworkImageView + button + datePicker + datePickerContainerView + musicTableView + navigationBar + nextButton + previousButton + segmentedControl + songLabel + timerLabel + timerTableView + volumeSlider + + + YES + + artistLabel + UILabel + + + artworkContainerView + UIView + + + artworkImageView + UIImageView + + + button + UIButton + + + datePicker + UIDatePicker + + + datePickerContainerView + UIView + + + musicTableView + UITableView + + + navigationBar + UINavigationBar + + + nextButton + UIButton + + + previousButton + UIButton + + + segmentedControl + UISegmentedControl + + + songLabel + UILabel + + + timerLabel + UILabel + + + timerTableView + UITableView + + + volumeSlider + UISlider + + + + + IBProjectSource + SleepTimerSettingsViewController.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIBarButtonItem + UIBarItem + + IBFrameworkSource + UIKit.framework/Headers/UIBarButtonItem.h + + + + UIBarItem + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIBarItem.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIDatePicker + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIDatePicker.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UINavigationBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UINavigationBar.h + + + + UINavigationItem + NSObject + + + + UIResponder + NSObject + + + + UIScrollView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIScrollView.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UISegmentedControl + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISegmentedControl.h + + + + UISlider + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISlider.h + + + + UITableView + UIScrollView + + IBFrameworkSource + UIKit.framework/Headers/UITableView.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + MediaPlayer.framework/Headers/MPMoviePlayerViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBIPadFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + YES + + YES + blackGlass.png + fastForward.png + lightTexturedBackground.png + rewind.png + segmentedControlMusicSelected.png + segmentedControlOceanWavesSelected.png + sleepTimerButton.png + stopSleepTimerButton.png + translucentScreen.png + + + YES + {320, 119} + {50, 50} + {320, 540} + {50, 50} + {160, 40} + {160, 40} + {320, 45} + {40, 42} + {320, 367} + + + 123 + + diff --git a/SleepTimerSettingsView.xib b/SleepTimerSettingsView.xib new file mode 100644 index 0000000..3860c36 --- /dev/null +++ b/SleepTimerSettingsView.xib @@ -0,0 +1,1497 @@ + + + + 784 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 123 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 292 + + YES + + + 256 + {320, 460} + + NO + YES + 4 + YES + IBCocoaTouchFramework + + NSImage + lightTexturedBackground.png + + + + + 292 + {{0, 51}, {320, 45}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + Helvetica-Bold + 14 + 16 + + {0, -1} + Start Sleep Timer + + 3 + MQA + + + + 1 + MC4yNTAzMDg4NDAyIDAuMzk3OTU5MTgzNyAwLjI3NDk5MTY5NAA + + + NSImage + sleepTimerButton.png + + + + + 292 + {{0, 106}, {160, 40}} + + NO + 2000 + IBCocoaTouchFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + NSImage + segmentedControlMusicSelected.png + + + + + 292 + {{160, 106}, {160, 40}} + + NO + 2001 + IBCocoaTouchFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + NSImage + segmentedControlOceanWavesDeselected.png + + + + + 274 + {{0, 154}, {320, 284}} + + + YES + IBCocoaTouchFramework + YES + NO + 0 + YES + 44 + 22 + 22 + + + + 292 + {{20, 335}, {280, 71}} + + NO + YES + NO + IBCocoaTouchFramework + When the sleep timer is done, it will automatically fade out the volume to avoid stopping abruptly. + + Helvetica + 15 + 16 + + + 1 + MCAwIDAAA + + + + 1 + MSAxIDEAA + + {0, 1} + 1 + NO + 10 + 6 + 1 + + + {320, 460} + + 1 + MC4wODE2MzI2NTMwNiAwLjA4MTYzMjY1MzA2IDAuMDgxNjMyNjUzMDYAA + + + IBCocoaTouchFramework + + + + 292 + + YES + + + 292 + {{0, 44}, {320, 216}} + + NO + YES + YES + IBCocoaTouchFramework + 0 + 0 + 3 + + en_US + + + America/Los_Angeles + + VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ +y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ +5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g +8n/BkPNvwKD0X6OQ9U+ioPY/hZD3L4Sg+CiiEPkPZqD6CIQQ+viDIPvoZhD82GUg/chIEP64RyD/qCoQ +AJgpIAGIDBACeAsgA3EokARhJ6AFUQqQBkEJoAcw7JAHjUOgCRDOkAmtvyAK8LCQC+CvoAzZzRANwJGg +DrmvEA+priAQmZEQEYmQIBJ5cxATaXIgFFlVEBVJVCAWOTcQFyk2IBgiU5AZCRggGgI1kBryNKAb4heQ +HNIWoB3B+ZAesfigH6HbkCB2KyAhgb2QIlYNICNq2hAkNe8gJUq8ECYV0SAnKp4QJ/7toCkKgBAp3s+g +KupiECu+saAs036QLZ6ToC6zYJAvfnWgMJNCkDFnkiAycySQM0d0IDRTBpA1J1YgNjLokDcHOCA4HAUQ +OOcaIDn75xA6xvwgO9vJEDywGKA9u6sQPo/6oD+bjRBAb9ygQYSpkEJPvqBDZIuQRC+goEVEbZBF89Mg +Ry2KEEfTtSBJDWwQSbOXIErtThBLnLOgTNZqkE18laBOtkyQT1x3oFCWLpBRPFmgUnYQkFMcO6BUVfKQ +VPwdoFY11JBW5TogWB7xEFjFHCBZ/tMQWqT+IFvetRBchOAgXb6XEF5kwiBfnnkQYE3eoGGHlZBiLcCg +Y2d3kGQNoqBlR1mQZe2EoGcnO5BnzWagaQcdkGmtSKBq5v+Qa5ZlIGzQHBBtdkcgbq/+EG9WKSBwj+AQ +cTYLIHJvwhBzFe0gdE+kEHT/CaB2OMCQdt7roHgYopB4vs2gefiEkHqer6B72GaQfH6RoH24SJB+XnOg +f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA + + + + 286485008.01363301 + + 1 + + + + 290 + {320, 44} + + NO + NO + IBCocoaTouchFramework + 1 + + YES + + + + + Done + IBCocoaTouchFramework + 1 + + + IBCocoaTouchFramework + + + + + {320, 260} + + + 3 + MSAwAA + + 2 + + + NO + NO + + 3 + + IBCocoaTouchFramework + + + + 292 + + YES + + + 256 + {{0, 44}, {320, 320}} + + NO + YES + 4 + YES + IBCocoaTouchFramework + + + + 256 + {320, 367} + + NO + YES + 4 + YES + IBCocoaTouchFramework + + NSImage + translucentScreen.png + + + + + 256 + {{0, 316}, {320, 75}} + + NO + YES + 4 + YES + IBCocoaTouchFramework + + NSImage + blackGlass.png + + + + + 292 + {{20, 232}, {280, 22}} + + NO + YES + NO + IBCocoaTouchFramework + Song title + + 1 + MSAxIDEAA + + 1 + + + + + 3 + MAA + + 1 + 10 + 1 + + + + 292 + {{20, 252}, {280, 22}} + + NO + YES + NO + IBCocoaTouchFramework + Song artist + + 1 + MSAxIDEAA + + + + + 1 + 10 + 1 + + + + 292 + {{30, 319}, {50, 50}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + NSImage + rewind.png + + + + + 292 + {{240, 319}, {50, 50}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + NSImage + fastForward.png + + + + + 292 + {{140, 323}, {40, 42}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + NSImage + stopSleepTimerButton.png + + + + + 292 + {{35, 70}, {250, 75}} + + NO + YES + NO + IBCocoaTouchFramework + 00:00:00 + + Helvetica + 64 + 16 + + + 1 + MSAxIDEAA + + + + + 1 + 10 + 1 + + + + 292 + {{28, 377}, {264, 23}} + + NO + IBCocoaTouchFramework + 0 + 0 + 0.5 + + + {320, 411} + + NO + IBCocoaTouchFramework + + + + + YES + + + view + + + + 3 + + + + setSleepTimerTime: + + + 13 + + 13 + + + + datePicker + + + + 14 + + + + button + + + + 24 + + + + toggleSleepTimer: + + + 7 + + 25 + + + + datePickerContainerView + + + + 48 + + + + toggleDatePicker: + + + + 52 + + + + artworkContainerView + + + + 55 + + + + artworkImageView + + + + 56 + + + + previousSong: + + + 7 + + 86 + + + + nextSong: + + + 7 + + 87 + + + + songLabel + + + + 88 + + + + artistLabel + + + + 89 + + + + toggleSleepTimer: + + + 7 + + 92 + + + + timerLabel + + + + 94 + + + + buttonSegmentTapped: + + + 7 + + 100 + + + + buttonSegmentTapped: + + + 7 + + 101 + + + + previousButton + + + + 102 + + + + nextButton + + + + 103 + + + + timerTableView + + + + 105 + + + + dataSource + + + + 106 + + + + delegate + + + + 107 + + + + volumeSlider + + + + 109 + + + + volumeSliderMoved: + + + 13 + + 110 + + + + + YES + + 0 + + + + + + 1 + + + YES + + + + + + + + + + + -1 + + + File's Owner + + + -2 + + + + + 12 + + + + + 23 + + + + + 47 + + + YES + + + + + Date Picker Container + + + 4 + + + + + 49 + + + YES + + + + + + 50 + + + YES + + + + + + 51 + + + + + 53 + + + YES + + + + + + + + + + + + + Artwork Container + + + 54 + + + + + 76 + + + + + 78 + + + + + 79 + + + + + 80 + + + + + 84 + + + + + 85 + + + + + 91 + + + + + 93 + + + + + 96 + + + + + 97 + + + + + 98 + + + + + 104 + + + + + 108 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 104.IBPluginDependency + 108.IBPluginDependency + 108.IBViewBoundsToFrameTransform + 23.IBPluginDependency + 4.IBPluginDependency + 47.IBEditorWindowLastContentRect + 47.IBPluginDependency + 49.IBPluginDependency + 50.IBPluginDependency + 51.IBPluginDependency + 53.IBEditorWindowLastContentRect + 53.IBPluginDependency + 79.IBPluginDependency + 80.IBPluginDependency + 84.IBPluginDependency + 85.IBPluginDependency + 91.IBPluginDependency + 93.IBPluginDependency + 96.IBPluginDependency + 97.IBPluginDependency + 98.IBPluginDependency + + + YES + SleepTimerSettingsViewController + UIResponder + {{570, -15}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABBuAAAw8SAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + {{582, 476}, {320, 260}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + {{302, 252}, {320, 411}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 110 + + + + YES + + SleepTimerSettingsViewController + UIViewController + + YES + + YES + buttonSegmentTapped: + chooseMusic: + doneButtonTapped: + nextSong: + previousSong: + setSleepTimerTime: + toggleDatePicker: + toggleSleepTimer: + volumeSliderMoved: + + + YES + UIButton + id + id + id + id + id + id + id + UISlider + + + + YES + + YES + buttonSegmentTapped: + chooseMusic: + doneButtonTapped: + nextSong: + previousSong: + setSleepTimerTime: + toggleDatePicker: + toggleSleepTimer: + volumeSliderMoved: + + + YES + + buttonSegmentTapped: + UIButton + + + chooseMusic: + id + + + doneButtonTapped: + id + + + nextSong: + id + + + previousSong: + id + + + setSleepTimerTime: + id + + + toggleDatePicker: + id + + + toggleSleepTimer: + id + + + volumeSliderMoved: + UISlider + + + + + YES + + YES + artistLabel + artworkContainerView + artworkImageView + button + datePicker + datePickerContainerView + musicTableView + navigationBar + nextButton + previousButton + segmentedControl + songLabel + timerLabel + timerTableView + volumeSlider + + + YES + UILabel + UIView + UIImageView + UIButton + UIDatePicker + UIView + UITableView + UINavigationBar + UIButton + UIButton + UISegmentedControl + UILabel + UILabel + UITableView + UISlider + + + + YES + + YES + artistLabel + artworkContainerView + artworkImageView + button + datePicker + datePickerContainerView + musicTableView + navigationBar + nextButton + previousButton + segmentedControl + songLabel + timerLabel + timerTableView + volumeSlider + + + YES + + artistLabel + UILabel + + + artworkContainerView + UIView + + + artworkImageView + UIImageView + + + button + UIButton + + + datePicker + UIDatePicker + + + datePickerContainerView + UIView + + + musicTableView + UITableView + + + navigationBar + UINavigationBar + + + nextButton + UIButton + + + previousButton + UIButton + + + segmentedControl + UISegmentedControl + + + songLabel + UILabel + + + timerLabel + UILabel + + + timerTableView + UITableView + + + volumeSlider + UISlider + + + + + IBProjectSource + SleepTimerSettingsViewController.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIBarButtonItem + UIBarItem + + IBFrameworkSource + UIKit.framework/Headers/UIBarButtonItem.h + + + + UIBarItem + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIBarItem.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIDatePicker + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIDatePicker.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UINavigationBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UINavigationBar.h + + + + UINavigationItem + NSObject + + + + UIResponder + NSObject + + + + UIScrollView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIScrollView.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UISegmentedControl + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISegmentedControl.h + + + + UISlider + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISlider.h + + + + UITableView + UIScrollView + + IBFrameworkSource + UIKit.framework/Headers/UITableView.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + MediaPlayer.framework/Headers/MPMoviePlayerViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + YES + + YES + blackGlass.png + fastForward.png + lightTexturedBackground.png + rewind.png + segmentedControlMusicSelected.png + segmentedControlOceanWavesDeselected.png + sleepTimerButton.png + stopSleepTimerButton.png + translucentScreen.png + + + YES + {320, 119} + {50, 50} + {320, 540} + {50, 50} + {160, 40} + {160, 40} + {320, 45} + {40, 42} + {320, 367} + + + 123 + + diff --git a/SleepTimerSettingsViewController.h b/SleepTimerSettingsViewController.h new file mode 100644 index 0000000..82ac812 --- /dev/null +++ b/SleepTimerSettingsViewController.h @@ -0,0 +1,64 @@ +// +// SleepTimerSettingsViewController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 1/29/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import +#import +#import "ShadowedLabel.h" + +@interface SleepTimerSettingsViewController : UIViewController { + IBOutlet UISegmentedControl *segmentedControl; + IBOutlet UIDatePicker *datePicker; + IBOutlet UITableView *musicTableView; + IBOutlet UITableView *timerTableView; + IBOutlet UIButton *button; + IBOutlet UIView *datePickerContainerView; + IBOutlet UIView *artworkContainerView; + IBOutlet UIImageView *artworkImageView; + IBOutlet UILabel *timerLabel; + IBOutlet UILabel *songLabel; + IBOutlet UILabel *artistLabel; + IBOutlet UINavigationBar *navigationBar; + IBOutlet UIButton *previousButton; + IBOutlet UIButton *nextButton; + IBOutlet UISlider *volumeSlider; + + BOOL datePickerIsShowing; + UITableViewCell *musicCell; + ShadowedLabel *hourLabel2; + ShadowedLabel *hourLabel1; + ShadowedLabel *minuteLabel1; + ShadowedLabel *minuteLabel2; + + int secondsLeftOnTimer; +} + +//- (void)segmentedControlTapped:(id)sender; +- (void)setTimerString; +- (void)setSongArtworkAndLabels; +- (void)setButtonSegmentImages; +- (IBAction)nextSong:(id)sender; +- (IBAction)previousSong:(id)sender; + +- (IBAction)setSleepTimerTime:(id)sender; +- (IBAction)toggleSleepTimer:(id)sender; +- (IBAction)chooseMusic: (id) sender; +- (IBAction)doneButtonTapped:(id)sender; +- (IBAction)buttonSegmentTapped:(UIButton *)sender; +- (IBAction)volumeSliderMoved:(UISlider *)sender; + +- (void)showArtworkContainerView; +- (void)hideArtworkContainerView; + +- (void)updateTimerLabel:(NSTimer *)theTimer; +- (void)setLabelInMusicCell; + +- (IBAction)toggleDatePicker:(id)sender; + +@property (nonatomic, retain) UITableViewCell *musicCell; + +@end diff --git a/SleepTimerSettingsViewController.m b/SleepTimerSettingsViewController.m new file mode 100644 index 0000000..e64de67 --- /dev/null +++ b/SleepTimerSettingsViewController.m @@ -0,0 +1,725 @@ +// +// SleepTimerSettingsViewController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 1/29/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "SleepTimerSettingsViewController.h" +#import "Constants.h" +#import "Sleep_Blaster_touchAppDelegate.h" +#import "SleepTimerController.h" +#import "CustomUISwitch.h" +#import "AlarmSettingsViewController.h" +#import +#import "EmptyViewController.h" + +#define SLEEP_TIMER_LABEL_TAG 1000 + +@implementation SleepTimerSettingsViewController + +@synthesize musicCell; + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + + self.title = @"Sleep Timer"; + + UIImage* anImage = [UIImage imageNamed:@"hourGlassIcon.png"]; + UITabBarItem* theItem = [[UITabBarItem alloc] initWithTitle:@"Sleep Timer" image:anImage tag:0]; + self.tabBarItem = theItem; + [theItem release]; + + } + return self; +} + +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad { + [super viewDidLoad]; + + [SleepTimerController sharedSleepTimerController].interfaceDelegate = self; + + [self setButtonSegmentImages]; + + volumeSlider.backgroundColor = [UIColor clearColor]; + UIImage *stetchLeftTrack = [[UIImage imageNamed:@"blueTrack.png"] stretchableImageWithLeftCapWidth:4.0 topCapHeight:0.0]; + UIImage *stetchRightTrack = [[UIImage imageNamed:@"whiteTrack.png"] stretchableImageWithLeftCapWidth:4.0 topCapHeight:0.0]; + [volumeSlider setThumbImage: [UIImage imageNamed:@"whiteSlide.png"] forState:UIControlStateNormal]; + [volumeSlider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal]; + [volumeSlider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal]; + + volumeSlider.value = [MPMusicPlayerController iPodMusicPlayer].volume; + [self volumeSliderMoved:volumeSlider]; + + musicTableView.rowHeight = 60; + musicTableView.backgroundColor = [UIColor clearColor]; + timerTableView.rowHeight = 60; + timerTableView.backgroundColor = [UIColor clearColor]; + + // Initialize the datepicker + datePicker.countDownDuration = [[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerSeconds] intValue]; + CGRect datePickerContainerViewFrame = datePickerContainerView.frame; + datePickerContainerViewFrame.origin.y = self.view.frame.size.height; + datePickerContainerView.frame = datePickerContainerViewFrame; + [self.view addSubview:datePickerContainerView]; + datePickerIsShowing = NO; + + secondsLeftOnTimer = 0; + +// [[NSNotificationCenter defaultCenter] addObserver:self +// selector:@selector(nowPlayingItemChanged:) +// name:MPMusicPlayerControllerNowPlayingItemDidChangeNotification +// object:[MPMusicPlayerController applicationMusicPlayer]]; +// + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(userDefaultsChanged:) + name:NSUserDefaultsDidChangeNotification + object:[NSUserDefaults standardUserDefaults]]; +} + +- (void)setButtonSegmentImages +{ + int value = [[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue]; + if (value == 0) + { + [((UIButton *)[self.view viewWithTag:LEFT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlMusicSelected.png"] + forState:UIControlStateNormal]; + [((UIButton *)[self.view viewWithTag:RIGHT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlOceanWavesDeselected.png"] + forState:UIControlStateNormal]; + + } else if (value == 1 ) { + [((UIButton *)[self.view viewWithTag:LEFT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlMusicDeselected.png"] + forState:UIControlStateNormal]; + [((UIButton *)[self.view viewWithTag:RIGHT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlOceanWavesSelected.png"] + forState:UIControlStateNormal]; + } +} + +- (IBAction)buttonSegmentTapped:(UIButton *)sender +{ + if (sender.tag == LEFT_BUTTON_SEGMENT) + { + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue] != 0) + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:0] + forKey:kSleepTimerFunction]; + + // [musicTableView insertSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade]; + NSArray *indexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:0], [NSIndexPath indexPathForRow:2 inSection:0], nil]; + [timerTableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade]; + } + } else if (sender.tag == RIGHT_BUTTON_SEGMENT) + { + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue] != 1) + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:1] + forKey:kSleepTimerFunction]; + + // [musicTableView deleteSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade]; + + NSArray *indexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:0], [NSIndexPath indexPathForRow:2 inSection:0], nil]; + [timerTableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade]; + + } + } + [self setButtonSegmentImages]; +} + +- (void)nowPlayingItemChanged:(NSNotification *)notification +{ + NSLog(@"now playing item changed!"); + [self setSongArtworkAndLabels]; +} + +- (void)userDefaultsChanged:(NSNotification *)notification +{ + [self setTimerString]; +} + +- (IBAction)setSleepTimerTime:(id)sender +{ + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:[sender countDownDuration]] forKey:kSleepTimerSeconds]; +} + +- (IBAction)toggleSleepTimer:(id)sender +{ + if ([SleepTimerController sharedSleepTimerController].sleepTimerIsOn) + { + [self hideArtworkContainerView]; + [[NSNotificationCenter defaultCenter] removeObserver:self + name:MPMusicPlayerControllerNowPlayingItemDidChangeNotification + object:[MPMusicPlayerController applicationMusicPlayer]]; + [[SleepTimerController sharedSleepTimerController] stopSleepTimer:nil]; + +// self.title = @"Sleep Timer"; + } else { + [[MPMusicPlayerController applicationMusicPlayer] beginGeneratingPlaybackNotifications]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(nowPlayingItemChanged:) + name:MPMusicPlayerControllerNowPlayingItemDidChangeNotification + object:[MPMusicPlayerController applicationMusicPlayer]]; + + [[SleepTimerController sharedSleepTimerController] startSleepTimer]; + + secondsLeftOnTimer = [[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerSeconds] intValue]; + [self updateTimerLabel:nil]; + [NSTimer scheduledTimerWithTimeInterval:1.0 + target:self + selector:@selector(updateTimerLabel:) + userInfo:nil repeats:YES]; +// self.title = @"Sleep Timer"; + + [self setSongArtworkAndLabels]; + [self showArtworkContainerView]; + } +} + +- (void)updateTimerLabel:(NSTimer *)theTimer +{ + if (![SleepTimerController sharedSleepTimerController].sleepTimerIsOn) + { + [theTimer invalidate]; + } + + int hours = floor(secondsLeftOnTimer/3600); + int minutes = floor((secondsLeftOnTimer-(hours*3600))/60); + int seconds = (secondsLeftOnTimer-(hours*3600)-(minutes*60)); + NSString *timeString = [NSString stringWithFormat:@"%d:%02d:%02d", hours, minutes, seconds]; + + timerLabel.text = timeString; + + secondsLeftOnTimer--; +} + +- (void)showArtworkContainerView +{ + + CGRect artworkContainerViewFrame = artworkContainerView.frame; + + if (!artworkContainerView.superview) // add the artwork container view as a subview, IF it hasn't been added already. + { + artworkContainerViewFrame.origin.y = self.view.frame.size.height; + artworkContainerView.frame = artworkContainerViewFrame; + [self.view addSubview:artworkContainerView]; + } + + artworkContainerViewFrame.origin.y = self.view.frame.size.height - artworkContainerViewFrame.size.height; +// artworkContainerViewFrame.origin.y = 0.0; + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.5]; + artworkContainerView.frame = artworkContainerViewFrame; + [UIView commitAnimations]; +} + +- (void)hideArtworkContainerView +{ + CGRect artworkContainerViewFrame = artworkContainerView.frame; + artworkContainerViewFrame.origin.y = self.view.frame.size.height; + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.5]; + //artworkContainerView.transform = CGAffineTransformMakeTranslation(0, (artworkContainerView.frame.size.height)); + artworkContainerView.frame = artworkContainerViewFrame; + [UIView commitAnimations]; + // [artworkContainerView removeFromSuperview]; +} + +- (void)setSongArtworkAndLabels +{ + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue] == 0) + { + previousButton.hidden = NO; + nextButton.hidden = NO; + + songLabel.text = [[MPMusicPlayerController applicationMusicPlayer].nowPlayingItem valueForProperty:MPMediaItemPropertyTitle]; + artistLabel.text = [[MPMusicPlayerController applicationMusicPlayer].nowPlayingItem valueForProperty:MPMediaItemPropertyArtist]; + + UIImage *artwork = [[[MPMusicPlayerController applicationMusicPlayer].nowPlayingItem valueForProperty:MPMediaItemPropertyArtwork] imageWithSize:artworkImageView.frame.size]; + if (artwork) { + artworkImageView.image = artwork; + } else { + artworkImageView.image = [UIImage imageNamed:@"NoArtwork.tif"]; + } + } else if ([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue] == 1) { + previousButton.hidden = YES; + nextButton.hidden = YES; + + songLabel.text = @""; + artistLabel.text = @""; + artworkImageView.image = [UIImage imageNamed:@"NoArtwork.tif"]; + } +} + +- (IBAction) chooseMusic: (id) sender { + + MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAnyAudio]; + + picker.delegate = self; + picker.allowsPickingMultipleItems = YES; + picker.prompt = NSLocalizedString (@"Add songs to fall asleep to", "Prompt in media item picker"); + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + picker.modalPresentationStyle = UIModalPresentationCurrentContext; + } + // The media item picker uses the default UI style, so it needs a default-style + // status bar to match it visually + [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: YES]; + + + [self.tabBarController presentModalViewController:picker animated:YES]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { +// Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + CGSize size = {320, 480}; + self.contentSizeForViewInPopover = size; + } + [picker release]; +} + +// Responds to the user tapping Done after choosing music. +- (void) mediaPicker:(MPMediaPickerController *) mediaPicker + didPickMediaItems:(MPMediaItemCollection *) mediaItemCollection +{ + + [self.tabBarController dismissModalViewControllerAnimated:YES]; + + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + CGSize size = {320, 480}; + self.contentSizeForViewInPopover = size; + size.height += 37; + [mainDelegate.clockViewController.alarmPopoverController setPopoverContentSize:size]; + [mainDelegate.clockViewController.alarmPopoverController dismissPopoverAnimated:NO]; + [mainDelegate.clockViewController.alarmPopoverController presentPopoverFromRect:mainDelegate.clockViewController.rightSettingsButton.frame inView:mainDelegate.clockViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO]; + } + // Save the alarm songs collection to the user defaults... + + NSData *sleepTimerSongsData = [NSKeyedArchiver archivedDataWithRootObject:mediaItemCollection]; + [[NSUserDefaults standardUserDefaults] setObject:sleepTimerSongsData forKey:kSleepTimerSongsCollection]; + + mainDelegate.sleepTimerSongsCollection = mediaItemCollection; + +/* NSString *musicString; + if ([mediaItemCollection.items count] > 1) { + musicString = [NSString stringWithFormat:@"%d songs", [mediaItemCollection.items count]]; + } else { + musicString = [[mediaItemCollection.items objectAtIndex:0] valueForProperty:MPMediaItemPropertyTitle]; + } + + [self.musicCell.textLabel setText:musicString]; +*/ + [self setLabelInMusicCell]; + + [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque animated:YES]; + +} + +// Responds to the user tapping done having chosen no music. +- (void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker { + + [self.tabBarController dismissModalViewControllerAnimated:YES]; + + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + CGSize size = {320, 480}; + self.contentSizeForViewInPopover = size; + size.height += 37; + [mainDelegate.clockViewController.alarmPopoverController setPopoverContentSize:size]; + [mainDelegate.clockViewController.alarmPopoverController dismissPopoverAnimated:NO]; + [mainDelegate.clockViewController.alarmPopoverController presentPopoverFromRect:mainDelegate.clockViewController.rightSettingsButton.frame inView:mainDelegate.clockViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO]; + } + [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque animated:YES]; +} + + +/* +// Override to allow orientations other than the default portrait orientation. +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations + return (interfaceOrientation == UIInterfaceOrientationPortrait); +} +*/ + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + +- (void)viewWillAppear:(BOOL)animated +{ + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + CGSize size = {320, 480}; + self.contentSizeForViewInPopover = size; + } +// size.height += (37+44); // For some reason, only here, we have to add 37 pixels to the height. It has something to do with the navigation controller. +// Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; +// [mainDelegate.clockViewController.alarmPopoverController setPopoverContentSize:size]; + +} + +- (void)dealloc { + [super dealloc]; +} + +- (void)switchFlipped:(UISwitch *)sender +{ + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[sender isOn]] forKey:kSleepTimerMusicShuffle]; +} + +- (IBAction)doneButtonTapped:(id)sender +{ + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + [mainDelegate flipToClockView:sender]; +} + +- (void)setLabelInMusicCell +{ + Sleep_Blaster_touchAppDelegate *mainDelegate = (Sleep_Blaster_touchAppDelegate *)[[UIApplication sharedApplication] delegate]; + NSString *musicString = nil; + + if (mainDelegate.hasLoadedSleepTimerSongsCollection) // if it's finished loading (whether there's any song data or not)... + { + if (!mainDelegate.sleepTimerSongsCollection) { + musicString = @"Select songs"; + } else if (mainDelegate.sleepTimerSongsCollection.count > 1) { + musicString = [NSString stringWithFormat:@"%d songs", mainDelegate.sleepTimerSongsCollection.items.count]; + } else if (mainDelegate.sleepTimerSongsCollection.count == 1) { + musicString = [[mainDelegate.sleepTimerSongsCollection.items objectAtIndex:0] valueForProperty:MPMediaItemPropertyTitle]; + } + [self.musicCell.textLabel setText:musicString]; + } else { // otherwise, it hasn't finished loading yet. + musicCell.textLabel.text = @"Loading songs..."; + } +} + +- (void)setTimerString +{ + NSLog(@"setting timer string"); + + int hours = floor([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerSeconds] intValue]/3600); + int minutes = floor(([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerSeconds] intValue]-(hours*3600))/60); + NSString *timerString = [NSString stringWithFormat:@"%dhr %dmin", hours, minutes]; + +// int hoursTensDigit = floor(hours/10); +// int hoursOnesDigit = hours-(hoursTensDigit*10); +// int minutesTensDigit = floor(minutes/10); +// int minutesOnesDigit = minutes-(minutesTensDigit*10); + + + ShadowedLabel *blueLabel = (ShadowedLabel *)[self.view viewWithTag:SLEEP_TIMER_LABEL_TAG]; + blueLabel.text = timerString; + +// hourLabel1.text = hoursTensDigit > 0 ? [NSString stringWithFormat:@"%d", hoursTensDigit] : @""; +// hourLabel2.text = [NSString stringWithFormat:@"%d", hoursOnesDigit]; +// minuteLabel1.text = [NSString stringWithFormat:@"%d", minutesTensDigit]; +// minuteLabel2.text = [NSString stringWithFormat:@"%d", minutesOnesDigit]; +} + + +- (IBAction)toggleDatePicker:(id)sender +{ + CGRect frame = datePickerContainerView.frame; + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.5]; + + if (datePickerIsShowing) + { + frame.origin.y = self.view.frame.size.height; + + // datePickerContainerView.transform = CGAffineTransformMakeTranslation(0, datePickerContainerView.frame.size.height+69); + datePickerIsShowing = NO; + } else { + frame.origin.y = self.view.frame.size.height - frame.size.height; + //datePickerContainerView.transform = CGAffineTransformMakeTranslation(0, -(datePickerContainerView.frame.size.height+69)); // Offset. + datePickerIsShowing = YES; + } + + datePickerContainerView.frame = frame; + + [UIView commitAnimations]; +} + +- (IBAction)previousSong:(id)sender +{ + [[MPMusicPlayerController applicationMusicPlayer] skipToPreviousItem]; +} + + +- (IBAction)nextSong:(UISlider *)sender +{ + [[MPMusicPlayerController applicationMusicPlayer] skipToNextItem]; +} + +- (IBAction)volumeSliderMoved:(UISlider *)sender +{ + [SleepTimerController sharedSleepTimerController].volume = sender.value; +} + +#pragma mark UITableViewDelegate + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ +// if (tableView == musicTableView) { +// if ([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue] == 0) +// { +// return 1; +// } else { +// return 0; +// } +// } else if (tableView == timerTableView) { + return 1; +// } +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + return nil; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + if ([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerFunction] intValue] == 0) { + return 3; + } else { + return 1; + } +} + + +- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath +{ + cell.opaque = NO; + cell.backgroundColor = [UIColor clearColor]; +} + +- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease]; + + cell.textLabel.backgroundColor = [UIColor clearColor]; + cell.textLabel.textColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1.0]; + cell.textLabel.highlightedTextColor = [UIColor colorWithRed:.1 green:.1 blue:.1 alpha:1.0]; + cell.textLabel.shadowColor = [UIColor whiteColor]; + cell.textLabel.shadowOffset = CGSizeMake(0, 1); + +// if (theTableView == musicTableView) { + switch ([indexPath row]) { + case 0: // this is for the music picker. + + [cell.textLabel setText:@"Timer"]; + + UIImage *blackScreen = [UIImage imageNamed:@"blackScreen.png"]; + UIImageView *lcdImageView = [[UIImageView alloc] initWithFrame:CGRectMake(195.0, timerTableView.rowHeight/2-blackScreen.size.height/2, blackScreen.size.width, blackScreen.size.height)]; + [lcdImageView setImage:blackScreen]; + [cell.contentView addSubview:lcdImageView]; + +// hourLabel1 = [AlarmSettingsViewController createDigitLabel]; +// hourLabel1.frame = CGRectMake(6.0, 0.0, 10.0, 34.0); +// [lcdImageView addSubview:hourLabel1]; +// +// hourLabel2 = [AlarmSettingsViewController createDigitLabel]; +// hourLabel2.frame = CGRectMake(15.0, 0.0, 10.0, 34.0); +// [lcdImageView addSubview:hourLabel2]; +// +// minuteLabel1 = [AlarmSettingsViewController createDigitLabel]; +// minuteLabel1.frame = CGRectMake(56.0, 0.0, 10.0, 34.0); +// [lcdImageView addSubview:minuteLabel1]; +// +// minuteLabel2 = [AlarmSettingsViewController createDigitLabel]; +// minuteLabel2.frame = CGRectMake(65.0, 0.0, 10.0, 34.0); +// [lcdImageView addSubview:minuteLabel2]; +// +// ShadowedLabel *hrLabel = [AlarmSettingsViewController createDigitLabel]; +// hrLabel.frame = CGRectMake(27.0, 0.0, 23.0, 34.0); +// hrLabel.textAlignment = UITextAlignmentCenter; +// hrLabel.text = @"hr"; +// [lcdImageView addSubview:hrLabel]; +// +// ShadowedLabel *minLabel = [AlarmSettingsViewController createDigitLabel]; +// minLabel.frame = CGRectMake(77.0, 0.0, 27.0, 34.0); +// minLabel.textAlignment = UITextAlignmentCenter; +// minLabel.text = @"min"; +// [lcdImageView addSubview:minLabel]; +// +// [self setTimerDigitLabels]; + + ShadowedLabel *blueLabel = [[ShadowedLabel alloc] initWithFrame:CGRectMake(lcdImageView.frame.origin.x+lcdImageView.frame.size.width/2-100.0/2, (timerTableView.rowHeight/2)-(27.0/2), 100.0, 27.0)]; + blueLabel.textAlignment = UITextAlignmentCenter; + blueLabel.font = [UIFont boldSystemFontOfSize:12.0]; + blueLabel.textColor = [UIColor colorWithRed:.72 green:.91 blue:1.0 alpha:1.0]; + blueLabel.shadowColor = [UIColor colorWithRed:0.0 green:.52 blue:1.0 alpha:.9]; + blueLabel.shadowBlur = 10.0; + blueLabel.backgroundColor = [UIColor clearColor]; +// [blueLabel setText:[[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerSeconds] stringValue]]; + blueLabel.tag = SLEEP_TIMER_LABEL_TAG; + + int hours = floor([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerSeconds] intValue]/3600); + int minutes = floor(([[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerSeconds] intValue]-(hours*3600))/60); + NSString *timerString = [NSString stringWithFormat:@"%dhr %dmin", hours, minutes]; + blueLabel.text = timerString; + + [cell.contentView addSubview:blueLabel]; + + // [blueLabel release]; + + // [self setTimerString]; + + break; + + case 1: // this is for the music picker. + self.musicCell = cell; + + [self setLabelInMusicCell]; + //[NSThread detachNewThreadSelector:@selector(setLabelInMusicCell) toTarget:self withObject:nil]; + + UIImage *disclosure = [UIImage imageNamed:@"disclosure-iPad.png"]; + UIImageView *disclosureImageView = [[UIImageView alloc] initWithFrame:CGRectMake(250.0, timerTableView.rowHeight/2-disclosure.size.height/2, disclosure.size.width, disclosure.size.height)]; + [disclosureImageView setImage:disclosure]; + [disclosureImageView setOpaque:NO]; + [cell.contentView addSubview:disclosureImageView]; + + break; + + case 2: // this is for the "shuffle switch. + [cell.textLabel setText:@"Shuffle"]; + + CustomUISwitch *shuffleSwitch = [AlarmSettingsViewController createSwitch]; + CGRect frame = shuffleSwitch.frame; + frame.origin.y = timerTableView.rowHeight/2-frame.size.height/2; + shuffleSwitch.frame = frame; + + [shuffleSwitch addTarget:self action:@selector(switchFlipped:) forControlEvents:UIControlEventValueChanged]; + [shuffleSwitch setOn:[[[NSUserDefaults standardUserDefaults] objectForKey:kSleepTimerMusicShuffle] boolValue] animated:YES]; + + [cell.contentView addSubview:shuffleSwitch]; + + break; + default: + break; + } + + UIImage *rowBackground; + UIImage *selectionBackground; + NSInteger row = [indexPath row]; + +// NSString *backgroundImageName = [NSString stringWithFormat:@"section2Row%d.png", row]; +// NSString *selectedBackgroundImageName = [NSString stringWithFormat:@"section2Row%dSelected.png", row]; + + if (row == 0) + { + rowBackground = [UIImage imageNamed:@"lightRowTop.png"]; + selectionBackground = [UIImage imageNamed:@"lightRowTop.png"]; + } else { + rowBackground = [UIImage imageNamed:@"lightRow.png"]; + selectionBackground = [UIImage imageNamed:@"lightRow.png"]; + } + +// rowBackground = [UIImage imageNamed:backgroundImageName]; +// selectionBackground = [UIImage imageNamed:selectedBackgroundImageName]; + + UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectZero]; + UIImageView *selectedBackgroundImageView = [[UIImageView alloc] initWithFrame:CGRectZero]; + backgroundImageView.image = rowBackground; + selectedBackgroundImageView.image = selectionBackground; + + [cell setBackgroundView:backgroundImageView]; + [cell setSelectedBackgroundView:selectedBackgroundImageView]; + +// } else if (theTableView == timerTableView) { +// [cell.textLabel setText:@"Timer"]; +// +// UIImage *lcd = [UIImage imageNamed:@"sleepTimerMiniLCD.png"]; +// UIImageView *lcdImageView = [[UIImageView alloc] initWithFrame:CGRectMake(180.0, 6.0, lcd.size.width, lcd.size.height)]; +// [lcdImageView setImage:lcd]; +// [lcdImageView setOpaque:NO]; +// +// hourLabel1 = [AlarmSettingsViewController createDigitLabel]; +// hourLabel1.frame = CGRectMake(6.0, 0.0, 10.0, 34.0); +// [lcdImageView addSubview:hourLabel1]; +// +// hourLabel2 = [AlarmSettingsViewController createDigitLabel]; +// hourLabel2.frame = CGRectMake(15.0, 0.0, 10.0, 34.0); +// [lcdImageView addSubview:hourLabel2]; +// +// minuteLabel1 = [AlarmSettingsViewController createDigitLabel]; +// minuteLabel1.frame = CGRectMake(56.0, 0.0, 10.0, 34.0); +// [lcdImageView addSubview:minuteLabel1]; +// +// minuteLabel2 = [AlarmSettingsViewController createDigitLabel]; +// minuteLabel2.frame = CGRectMake(65.0, 0.0, 10.0, 34.0); +// [lcdImageView addSubview:minuteLabel2]; +// +// ShadowedLabel *hrLabel = [AlarmSettingsViewController createDigitLabel]; +// hrLabel.frame = CGRectMake(27.0, 0.0, 23.0, 34.0); +// hrLabel.textAlignment = UITextAlignmentCenter; +// hrLabel.text = @"hr"; +// [lcdImageView addSubview:hrLabel]; +// +// ShadowedLabel *minLabel = [AlarmSettingsViewController createDigitLabel]; +// minLabel.frame = CGRectMake(77.0, 0.0, 27.0, 34.0); +// minLabel.textAlignment = UITextAlignmentCenter; +// minLabel.text = @"min"; +// [lcdImageView addSubview:minLabel]; +// +// [self setTimerDigitLabels]; +// +// [cell.contentView addSubview:lcdImageView]; +// +// UIImage *rowBackground; +// UIImage *selectionBackground; +// +//// NSString *backgroundImageName = @"sleepTimerTableView.png"; +//// NSString *selectedBackgroundImageName = @"sleepTimerTableViewSelected.png"; +// +//// rowBackground = [UIImage imageNamed:backgroundImageName]; +//// selectionBackground = [UIImage imageNamed:selectedBackgroundImageName]; +// rowBackground = [UIImage imageNamed:@"lightRow.png"]; +// selectionBackground = [UIImage imageNamed:@"lightRow.png"]; +// +// UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectZero]; +// UIImageView *selectedBackgroundImageView = [[UIImageView alloc] initWithFrame:CGRectZero]; +// backgroundImageView.image = rowBackground; +// selectedBackgroundImageView.image = selectionBackground; +// +// [cell setBackgroundView:backgroundImageView]; +// [cell setSelectedBackgroundView:selectedBackgroundImageView]; +// } + + return cell; +} + +- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [aTableView deselectRowAtIndexPath:indexPath animated:YES]; +} + +- (NSIndexPath *)tableView:(UITableView *)aTableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { +// if (aTableView == musicTableView) { + if (indexPath.row == 0) { + [self toggleDatePicker:self]; + } else if (indexPath.row == 1) { + // "Music" button tapped; bring up the music picker. + [self chooseMusic:self]; + } +// } else if (aTableView == timerTableView) { +// } + return indexPath; +} + +@end diff --git a/Sleep_Blaster_touch-Info.plist b/Sleep_Blaster_touch-Info.plist new file mode 100644 index 0000000..763e984 --- /dev/null +++ b/Sleep_Blaster_touch-Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDisplayName + Sleep Blaster + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFiles + + Icon.png + Icon-72.png + Icon@2x.png + + CFBundleIdentifier + com.the-byte-factory.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.5 + LSRequiresIPhoneOS + + NSMainNibFile + MainWindow + NSMainNibFile~ipad + MainWindow-iPad + UIBackgroundModes + + audio + location + + UIInterfaceOrientation + UIInterfaceOrientationPortrait + UIPrerenderedIcon + + UIStatusBarHidden + + + diff --git a/Sleep_Blaster_touch_Prefix.pch b/Sleep_Blaster_touch_Prefix.pch new file mode 100644 index 0000000..efd734f --- /dev/null +++ b/Sleep_Blaster_touch_Prefix.pch @@ -0,0 +1,8 @@ +// +// Prefix header for all source files of the 'Sleep Blaster touch' target in the 'Sleep Blaster touch' project +// + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/SpeakHereAppDelegate.h b/SpeakHereAppDelegate.h new file mode 100644 index 0000000..7e6dc48 --- /dev/null +++ b/SpeakHereAppDelegate.h @@ -0,0 +1,63 @@ +/* + + File: SpeakHereAppDelegate.h +Abstract: Application delegate for SpeakHere + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#import + +@class SpeakHereViewController; + +@interface SpeakHereAppDelegate : NSObject { + UIWindow *window; + SpeakHereViewController *viewController; +} + +@property (nonatomic, retain) IBOutlet UIWindow *window; +@property (nonatomic, retain) IBOutlet SpeakHereViewController *viewController; + +@end + diff --git a/SpeakHereAppDelegate.m b/SpeakHereAppDelegate.m new file mode 100644 index 0000000..4997541 --- /dev/null +++ b/SpeakHereAppDelegate.m @@ -0,0 +1,74 @@ +/* + + File: SpeakHereAppDelegate.m +Abstract: Application delegate for SpeakHere + Version: 2.2 + +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Inc. ("Apple") in consideration of your agreement to the following +terms, and your use, installation, modification or redistribution of +this Apple software constitutes acceptance of these terms. If you do +not agree with these terms, please do not use, install, modify or +redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Inc. may +be used to endorse or promote products derived from the Apple Software +without specific prior written permission from Apple. Except as +expressly stated in this notice, no other rights or licenses, express or +implied, are granted by Apple herein, including but not limited to any +patent rights that may be infringed by your derivative works or by other +works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright (C) 2009 Apple Inc. All Rights Reserved. + + +*/ + +#import "SpeakHereAppDelegate.h" +#import "SpeakHereViewController.h" + +@implementation SpeakHereAppDelegate + +@synthesize window; +@synthesize viewController; + + +- (void)applicationDidFinishLaunching:(UIApplication *)application { + + // Override point for customization after app launch + [window addSubview:viewController.view]; + [window makeKeyAndVisible]; +} + + +- (void)dealloc { + [viewController release]; + [window release]; + [super dealloc]; +} + + +@end diff --git a/TimeBar.png b/TimeBar.png new file mode 100644 index 0000000..9a01f3d Binary files /dev/null and b/TimeBar.png differ diff --git a/VoiceSettingsView-iPad.xib b/VoiceSettingsView-iPad.xib new file mode 100644 index 0000000..840bf93 --- /dev/null +++ b/VoiceSettingsView-iPad.xib @@ -0,0 +1,741 @@ + + + + 1024 + 10F569 + 788 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 117 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + 301 + + YES + + + 256 + {320, 540} + + NO + YES + 4 + YES + IBIPadFramework + + NSImage + lightTexturedBackground.png + + + + + 274 + {{0, 119}, {320, 180}} + + + 3 + MQA + + NO + YES + NO + IBIPadFramework + NO + NO + 1 + 0 + YES + 44 + 22 + 22 + + + + 292 + {{20, 0}, {280, 117}} + + NO + YES + NO + IBIPadFramework + To use Voice Controls, place your iPhone within 2ft of your bed. When the alarm rings, the music will play for a few seconds, then pause to listen for you yelling, then play for a few seconds, etc. + + Helvetica + 15 + 16 + + + 1 + MCAwIDAAA + + + + {0, 1} + 1 + NO + 10 + 6 + 1 + + + + 292 + {{74, 305}, {172, 20}} + + NO + YES + NO + IBIPadFramework + When I yell, that means... + + + + + {0, 1} + 1 + NO + 10 + 6 + 1 + + + + 292 + {{62, 330}, {103, 40}} + + NO + 2000 + IBIPadFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + NSImage + segmentedControlSnooze-iPad.png + + + + + 292 + {{165, 330}, {103, 40}} + + NO + 2001 + IBIPadFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + NSImage + segmentedControlStop-iPad.png + + + + {320, 540} + + + NO + IBIPadFramework + + + + + YES + + + view + + + + 10 + + + + tableView + + + + 11 + + + + dataSource + + + + 12 + + + + delegate + + + + 13 + + + + buttonSegmentTapped: + + + 7 + + 14 + + + + buttonSegmentTapped: + + + 7 + + 15 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 3 + + + YES + + + + + + + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 3.IBEditorWindowLastContentRect + 3.IBPluginDependency + 4.IBPluginDependency + 5.IBPluginDependency + 6.IBPluginDependency + 7.IBPluginDependency + 8.IBPluginDependency + + + YES + VoiceSettingsViewController + UIResponder + {{320, 87}, {320, 540}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 15 + + + + YES + + VoiceSettingsViewController + UIViewController + + YES + + YES + buttonSegmentTapped: + clearDigits: + enterDigit: + switchFlipped: + toggleKeypad: + + + YES + id + id + id + UISwitch + id + + + + YES + + YES + buttonSegmentTapped: + clearDigits: + enterDigit: + switchFlipped: + toggleKeypad: + + + YES + + buttonSegmentTapped: + id + + + clearDigits: + id + + + enterDigit: + id + + + switchFlipped: + UISwitch + + + toggleKeypad: + id + + + + + YES + + YES + keypadView + segmentedControl + tableView + + + YES + UIView + UISegmentedControl + UITableView + + + + YES + + YES + keypadView + segmentedControl + tableView + + + YES + + keypadView + UIView + + + segmentedControl + UISegmentedControl + + + tableView + UITableView + + + + + IBProjectSource + VoiceSettingsViewController.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UIResponder + NSObject + + + + UIScrollView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIScrollView.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UISegmentedControl + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISegmentedControl.h + + + + UISwitch + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISwitch.h + + + + UITableView + UIScrollView + + IBFrameworkSource + UIKit.framework/Headers/UITableView.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + MediaPlayer.framework/Headers/MPMoviePlayerViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBIPadFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + YES + + YES + lightTexturedBackground.png + segmentedControlSnooze-iPad.png + segmentedControlStop-iPad.png + + + YES + {320, 540} + {103, 40} + {103, 40} + + + 117 + + diff --git a/VoiceSettingsView.xib b/VoiceSettingsView.xib new file mode 100644 index 0000000..29f77cc --- /dev/null +++ b/VoiceSettingsView.xib @@ -0,0 +1,747 @@ + + + + 784 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 123 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 292 + + YES + + + 256 + {320, 480} + + NO + YES + 4 + YES + IBCocoaTouchFramework + + NSImage + lightTexturedBackground.png + + + + + 274 + {{0, 169}, {320, 180}} + + + 3 + MQA + + NO + YES + NO + IBCocoaTouchFramework + NO + NO + 0 + YES + 44 + 22 + 22 + + + + 292 + {{20, 44}, {280, 117}} + + NO + YES + NO + IBCocoaTouchFramework + To use Voice Controls, place your iPhone within 2ft of your bed. When the alarm rings, the music will play for a few seconds, then pause to listen for you yelling, then play for a few seconds, etc. + + Helvetica + 15 + 16 + + + 1 + MCAwIDAAA + + + + 1 + MSAxIDEAA + + {0, 1} + 1 + NO + 10 + 6 + 1 + + + + 292 + {{74, 375}, {172, 20}} + + NO + YES + NO + IBCocoaTouchFramework + When I yell, that means... + + + + + {0, 1} + 1 + NO + 10 + 6 + 1 + + + + 292 + {{62, 400}, {103, 40}} + + NO + 2000 + IBCocoaTouchFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + NSImage + segmentedControlSnoozeSelected.png + + + + + 292 + {{165, 400}, {103, 40}} + + NO + 2001 + IBCocoaTouchFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + NSImage + segmentedControlStop.png + + + + {320, 480} + + + NO + IBCocoaTouchFramework + + + + + YES + + + view + + + + 3 + + + + dataSource + + + + 6 + + + + delegate + + + + 7 + + + + tableView + + + + 8 + + + + buttonSegmentTapped: + + + 7 + + 51 + + + + buttonSegmentTapped: + + + 7 + + 52 + + + + + YES + + 0 + + + + + + 1 + + + YES + + + + + + + + + + + -1 + + + File's Owner + + + -2 + + + + + 9 + + + + + 50 + + + + + 48 + + + + + 16 + + + + + 11 + + + + + 5 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 11.IBPluginDependency + 16.IBPluginDependency + 48.IBPluginDependency + 5.IBPluginDependency + 50.IBPluginDependency + + + YES + VoiceSettingsViewController + UIResponder + {{617, 224}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 52 + + + + YES + + VoiceSettingsViewController + UIViewController + + YES + + YES + buttonSegmentTapped: + clearDigits: + enterDigit: + switchFlipped: + toggleKeypad: + + + YES + id + id + id + UISwitch + id + + + + YES + + YES + buttonSegmentTapped: + clearDigits: + enterDigit: + switchFlipped: + toggleKeypad: + + + YES + + buttonSegmentTapped: + id + + + clearDigits: + id + + + enterDigit: + id + + + switchFlipped: + UISwitch + + + toggleKeypad: + id + + + + + YES + + YES + keypadView + segmentedControl + tableView + + + YES + UIView + UISegmentedControl + UITableView + + + + YES + + YES + keypadView + segmentedControl + tableView + + + YES + + keypadView + UIView + + + segmentedControl + UISegmentedControl + + + tableView + UITableView + + + + + IBProjectSource + VoiceSettingsViewController.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UIResponder + NSObject + + + + UIScrollView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIScrollView.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UISegmentedControl + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISegmentedControl.h + + + + UISwitch + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISwitch.h + + + + UITableView + UIScrollView + + IBFrameworkSource + UIKit.framework/Headers/UITableView.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + MediaPlayer.framework/Headers/MPMoviePlayerViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Sleep Blaster touch.xcodeproj + 3 + + YES + + YES + lightTexturedBackground.png + segmentedControlSnoozeSelected.png + segmentedControlStop.png + + + YES + {320, 540} + {103, 40} + {103, 40} + + + 123 + + diff --git a/VoiceSettingsViewController.h b/VoiceSettingsViewController.h new file mode 100644 index 0000000..258ecd7 --- /dev/null +++ b/VoiceSettingsViewController.h @@ -0,0 +1,33 @@ +// +// VoiceSettingsViewController.h +// Sleep Blaster touch +// +// Created by Eamon Ford on 2/25/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import +#import "KeypadViewController.h" +#import "ShadowedLabel.h" + +@interface VoiceSettingsViewController : UIViewController { + IBOutlet UITableView *tableView; + IBOutlet UISegmentedControl *segmentedControl; + IBOutlet UIView *keypadView; + + ShadowedLabel *playIntervalLabel; + ShadowedLabel *pauseIntervalLabel; + KeypadViewController *keypadViewController; + + BOOL keypadIsShowing; + NSString *currentlyEditingDefault; +} + +- (IBAction)buttonSegmentTapped:(id)sender; +- (void)setButtonSegmentImages; +- (void)switchFlipped:(UISwitch *)sender; +- (void)toggleKeypad:(id)sender; +- (IBAction)enterDigit:(id)sender; +- (IBAction)clearDigits:(id)sender; + +@end diff --git a/VoiceSettingsViewController.m b/VoiceSettingsViewController.m new file mode 100644 index 0000000..cca0d12 --- /dev/null +++ b/VoiceSettingsViewController.m @@ -0,0 +1,368 @@ +// +// VoiceSettingsViewController.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 2/25/10. +// Copyright 2010 The Byte Factory. All rights reserved. +// + +#import "VoiceSettingsViewController.h" +#import "Constants.h" +#import "AlarmSettingsViewController.h" +#import "CustomUISwitch.h" +#import "Sleep_Blaster_touchAppDelegate.h" + +@implementation VoiceSettingsViewController + +/* + // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + // Custom initialization + } + return self; +} +*/ + +- (void)viewWillAppear:(BOOL)animated +{ + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + CGSize size = {320, 540}; + self.contentSizeForViewInPopover = size; + } + [super viewWillAppear:animated]; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + keypadIsShowing = NO; + + [self setTitle:@"Voice Controls"]; + + tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + tableView.rowHeight = 60; + tableView.backgroundColor = [UIColor clearColor]; + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + // The device is an iPad running iPhone 3.2 or later. + [tableView setBackgroundView:nil]; + [tableView setBackgroundView:[[[UIView alloc] init] autorelease]]; + } + + [self setButtonSegmentImages]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(userDefaultsChanged:) + name:NSUserDefaultsDidChangeNotification + object:[NSUserDefaults standardUserDefaults]]; +} + +- (void)setButtonSegmentImages +{ + int value = [[[NSUserDefaults standardUserDefaults] objectForKey:kVoiceFunction] intValue]; + if (value == 0) + { + [((UIButton *)[self.view viewWithTag:LEFT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlSnoozeSelected.png"] + forState:UIControlStateNormal]; + [((UIButton *)[self.view viewWithTag:RIGHT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlStop.png"] + forState:UIControlStateNormal]; + + } else if (value == 1 ) { + [((UIButton *)[self.view viewWithTag:LEFT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlSnooze.png"] + forState:UIControlStateNormal]; + [((UIButton *)[self.view viewWithTag:RIGHT_BUTTON_SEGMENT]) setBackgroundImage:[UIImage imageNamed:@"segmentedControlStopSelected.png"] + forState:UIControlStateNormal]; + } +} + +- (IBAction)buttonSegmentTapped:(UIButton *)sender +{ + if (sender.tag == LEFT_BUTTON_SEGMENT) + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:0] + forKey:kVoiceFunction]; + } else if (sender.tag == RIGHT_BUTTON_SEGMENT) + { + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:1] + forKey:kVoiceFunction]; + } + + [self setButtonSegmentImages]; +} + +- (void)dealloc { + [super dealloc]; +} + +- (void)switchFlipped:(UISwitch *)sender +{ + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[sender isOn]] forKey:kEnableVoiceControls]; +} + +- (void)toggleKeypad:(id)sender +{ + if (keypadIsShowing) + { + // Get ready to move the keypadView out of visibility. + CGRect keypadViewFrame = keypadViewController.view.frame; + // keypadViewFrame.origin.y += (KEYPAD_HEIGHT_MINUS_SHADOW + BOTTOMBAR_HEIGHT); + keypadViewFrame.origin.y = self.view.frame.size.height; + + // Get ready to move the main view back down to fill the screen again. + CGRect mainViewFrame = self.view.frame; + mainViewFrame.origin.y += (KEYPAD_HEIGHT_MINUS_SHADOW - 75); + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:1.0]; + + self.view.frame = mainViewFrame; + keypadViewController.view.frame = keypadViewFrame; + + [UIView commitAnimations]; + + //[keypadView removeFromSuperview]; + + keypadIsShowing = NO; + } else { + // Add the keypadView as a subview, and stick it below the very bottom of the screen. + if (!keypadViewController) { + keypadViewController = [[[KeypadViewController alloc] initWithNibName:@"KeypadView" bundle:nil] retain]; + keypadViewController.delegate = self; + + [self.view.superview addSubview:keypadViewController.view]; + } + + CGRect keypadViewFrame = keypadViewController.view.frame; +// keypadViewFrame.origin.y = 480 - MENUBAR_HEIGHT - 20; // height of the screen minus the height of the menubar and the shadow + keypadViewFrame.origin.y = self.view.frame.size.height; + keypadViewController.view.frame = keypadViewFrame; + + // Get ready to move the keypadView into visibility. +// keypadViewFrame.origin.y -= (KEYPAD_HEIGHT_MINUS_SHADOW + BOTTOMBAR_HEIGHT); + keypadViewFrame.origin.y = self.view.frame.size.height - keypadViewFrame.size.height; + + // Get ready to move the main view up to make room for the keypadView. + CGRect mainViewFrame = self.view.frame; + mainViewFrame.origin.y -= (KEYPAD_HEIGHT_MINUS_SHADOW - 75); // let the keyboard "catch up" an additional 80 pixels + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:1.0]; + + self.view.frame = mainViewFrame; + keypadViewController.view.frame = keypadViewFrame; + + [UIView commitAnimations]; + + keypadIsShowing = YES; + + if ([sender class] == [UITableViewCell class]) { + if ([tableView indexPathForCell:sender].row == 1) { // the sender was the "play interval" cell + currentlyEditingDefault = kAlarmPlayInterval; + } else if ([tableView indexPathForCell:sender].row == 2) { // the sender was the "pause interval" cell + currentlyEditingDefault = kAlarmPauseInterval; + } + } + } +} + +- (IBAction)enterDigit:(id)sender +{ + int originalNumber = [[[NSUserDefaults standardUserDefaults] objectForKey:currentlyEditingDefault] intValue]; + + int newNumber = originalNumber * 10 + ((UIButton *)sender).tag; + if (newNumber >= 99) { + newNumber = ((UIButton *)sender).tag; // don't let it be more than two digits + } + + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:newNumber] forKey:currentlyEditingDefault]; +} + +- (IBAction)clearDigits:(id)sender +{ + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:0] forKey:currentlyEditingDefault]; +} + +- (void)userDefaultsChanged:(NSNotification *)notification +{ + [playIntervalLabel setText:[[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmPlayInterval] stringValue]]; + [pauseIntervalLabel setText:[[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmPauseInterval] stringValue]]; +} + +#pragma mark UITableViewDelegate + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + return nil; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return 3; +} + +- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath +{ + cell.opaque = NO; + cell.backgroundColor = [UIColor clearColor]; +} + +- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease]; + + cell.textLabel.backgroundColor = [UIColor clearColor]; + cell.textLabel.textColor = [UIColor colorWithRed:.1 green:.1 blue:.1 alpha:1.0]; + cell.textLabel.highlightedTextColor = [UIColor colorWithRed:.1 green:.1 blue:.1 alpha:1.0]; + cell.textLabel.shadowColor = [UIColor whiteColor]; + cell.textLabel.shadowOffset = CGSizeMake(0, 1); + +// CGRect borderFrame; +// NSString *numberString; + + if ([indexPath row] == 0) { + [cell.textLabel setText:@"Voice Controls"]; + + CustomUISwitch *onSwitch = [AlarmSettingsViewController createSwitch]; + CGRect newRect = onSwitch.frame; + newRect.origin.y = (tableView.rowHeight/2)-(newRect.size.height/2); + onSwitch.frame = newRect; + + [onSwitch addTarget:self action:@selector(switchFlipped:) forControlEvents:UIControlEventValueChanged]; + [onSwitch setOn:[[[NSUserDefaults standardUserDefaults] objectForKey:kEnableVoiceControls] boolValue] animated:YES]; + + [cell.contentView addSubview:onSwitch]; + + } else if ([indexPath row] == 1) { + + [cell.textLabel setText:@"Seconds to play"]; + +// UIImageView *borderImageView = [[[UIImageView alloc] initWithFrame:CGRectMake(250.0, (tableView.rowHeight/2)-(27.0/2), 26.0, 27.0)] autorelease]; +// [borderImageView setImage:[UIImage imageNamed:@"numberWell.png"]]; +// [cell.contentView addSubview:borderImageView]; + + UIImage *blackScreen = [UIImage imageNamed:@"blackScreen.png"]; + UIImageView *borderImageView = [[UIImageView alloc] initWithFrame:CGRectMake(195.0, (tableView.rowHeight/2)-(blackScreen.size.height/2), blackScreen.size.width, blackScreen.size.height)]; + [borderImageView setImage:blackScreen]; + [cell.contentView addSubview:borderImageView]; + +// playIntervalLabel = [[[UILabel alloc] initWithFrame:CGRectMake(250.0, (tableView.rowHeight/2)-(27.0/2), 26.0, 27.0)] autorelease]; +// playIntervalLabel.textAlignment = UITextAlignmentCenter; +// playIntervalLabel.font = [UIFont boldSystemFontOfSize:14.0]; +// playIntervalLabel.textColor = [UIColor colorWithRed:.69 green:.90 blue:.98 alpha:1]; +// playIntervalLabel.backgroundColor = [UIColor clearColor]; +// [playIntervalLabel setText:[[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmPlayInterval] stringValue]]; +// [cell.contentView addSubview:playIntervalLabel]; + + playIntervalLabel = [[ShadowedLabel alloc] initWithFrame:CGRectMake(borderImageView.frame.origin.x+borderImageView.frame.size.width/2-100.0/2, (tableView.rowHeight/2)-(27.0/2), 100.0, 27.0)]; + playIntervalLabel.textAlignment = UITextAlignmentCenter; + playIntervalLabel.font = [UIFont boldSystemFontOfSize:12.0]; + playIntervalLabel.textColor = [UIColor colorWithRed:.72 green:.91 blue:1.0 alpha:1.0]; + playIntervalLabel.shadowColor = [UIColor colorWithRed:0.0 green:.52 blue:1.0 alpha:.9]; + playIntervalLabel.shadowBlur = 10.0; + playIntervalLabel.backgroundColor = [UIColor clearColor]; + [playIntervalLabel setText:[[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmPlayInterval] stringValue]]; + [cell.contentView addSubview:playIntervalLabel]; + + [playIntervalLabel release]; + [borderImageView release]; + + } else if ([indexPath row] == 2) { + [cell.textLabel setText:@"Seconds to pause"]; + +// UIImageView *borderImageView = [[[UIImageView alloc] initWithFrame:CGRectMake(250.0, 9.0, 26.0, 27.0)] autorelease]; +// [borderImageView setImage:[UIImage imageNamed:@"numberWell.png"]]; +// [cell.contentView addSubview:borderImageView]; + + UIImage *blackScreen = [UIImage imageNamed:@"blackScreen.png"]; + UIImageView *borderImageView = [[UIImageView alloc] initWithFrame:CGRectMake(195.0, (tableView.rowHeight/2)-(blackScreen.size.height/2), blackScreen.size.width, blackScreen.size.height)]; + [borderImageView setImage:blackScreen]; + [cell.contentView addSubview:borderImageView]; + +// pauseIntervalLabel = [[[UILabel alloc] initWithFrame:CGRectMake(250.0, 9.0, 26.0, 27.0)] autorelease]; +// pauseIntervalLabel.textAlignment = UITextAlignmentCenter; +// pauseIntervalLabel.font = [UIFont boldSystemFontOfSize:14.0]; +// pauseIntervalLabel.textColor = [UIColor colorWithRed:.69 green:.90 blue:.98 alpha:1]; +// pauseIntervalLabel.backgroundColor = [UIColor clearColor]; +// [pauseIntervalLabel setText:[[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmPauseInterval] stringValue]]; +// [cell.contentView addSubview:pauseIntervalLabel]; + + pauseIntervalLabel = [[ShadowedLabel alloc] initWithFrame:CGRectMake(borderImageView.frame.origin.x+borderImageView.frame.size.width/2-100.0/2, (tableView.rowHeight/2)-(27.0/2), 100.0, 27.0)]; + pauseIntervalLabel.textAlignment = UITextAlignmentCenter; + pauseIntervalLabel.font = [UIFont boldSystemFontOfSize:12.0]; + pauseIntervalLabel.textColor = [UIColor colorWithRed:.72 green:.91 blue:1.0 alpha:1.0]; + pauseIntervalLabel.shadowColor = [UIColor colorWithRed:0.0 green:.52 blue:1.0 alpha:.9]; + pauseIntervalLabel.shadowBlur = 10.0; + pauseIntervalLabel.backgroundColor = [UIColor clearColor]; + [pauseIntervalLabel setText:[[[NSUserDefaults standardUserDefaults] objectForKey:kAlarmPauseInterval] stringValue]]; + [cell.contentView addSubview:pauseIntervalLabel]; + + } + + UIImage *rowBackground; + UIImage *selectionBackground; + NSInteger row = [indexPath row]; +// NSInteger section = [indexPath section]; + +// NSString *backgroundImageName = @""; +// NSString *selectedBackgroundImageName = @""; +// +// if (!(section == tableView.numberOfSections-1 && row == [tableView numberOfRowsInSection:section]-1)) +// { +// backgroundImageName = @"lightRow.png"; +// selectedBackgroundImageName = @"lightRow.png"; +// } + + if (row == 0) + { + rowBackground = [UIImage imageNamed:@"lightRowTop.png"]; + selectionBackground = [UIImage imageNamed:@"lightRowTop.png"]; + } else { + rowBackground = [UIImage imageNamed:@"lightRow.png"]; + selectionBackground = [UIImage imageNamed:@"lightRow.png"]; + } + +// NSString *backgroundImageName = [NSString stringWithFormat:@"vcTableRow%d.png", row]; +// NSString *selectedBackgroundImageName = [NSString stringWithFormat:@"vcTableRow%dSelected.png", row]; + +// rowBackground = [UIImage imageNamed:backgroundImageName]; +// selectionBackground = [UIImage imageNamed:selectedBackgroundImageName]; + + UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 250, 50)]; + UIImageView *selectedBackgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 250, 50)]; + backgroundImageView.image = rowBackground; + selectedBackgroundImageView.image = selectionBackground; + + [cell setBackgroundView:backgroundImageView]; + [cell setSelectedBackgroundView:selectedBackgroundImageView]; + + return cell; +} + +- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [aTableView deselectRowAtIndexPath:indexPath animated:YES]; +} + +- (NSIndexPath *)tableView:(UITableView *)aTableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { + if (indexPath.row == 1 || indexPath.row == 2) { + [self toggleKeypad:[tableView cellForRowAtIndexPath:indexPath]]; + } + return indexPath; +} + +- (UIButton *) getDetailDiscolosureIndicatorForIndexPath: (NSIndexPath *) indexPath +{ + UIButton *button = [UIButton buttonWithType: UIButtonTypeDetailDisclosure]; + button.frame = CGRectMake(320.0 - 44.0, 0.0, 44.0, 44.0); + [button addTarget:self action:@selector(AddMusicOrShowMusic:) forControlEvents:UIControlEventTouchUpInside]; + return button; +} + +@end diff --git a/alarm.mp3 b/alarm.mp3 new file mode 100644 index 0000000..bd1c7b0 Binary files /dev/null and b/alarm.mp3 differ diff --git a/alarmMiniLCD.png b/alarmMiniLCD.png new file mode 100644 index 0000000..3b011bd Binary files /dev/null and b/alarmMiniLCD.png differ diff --git a/alarmOffButton.png b/alarmOffButton.png new file mode 100644 index 0000000..0b1bb6c Binary files /dev/null and b/alarmOffButton.png differ diff --git a/alarmRingingBottomBar.png b/alarmRingingBottomBar.png new file mode 100644 index 0000000..3296b80 Binary files /dev/null and b/alarmRingingBottomBar.png differ diff --git a/beep.wav b/beep.wav new file mode 100644 index 0000000..f651b10 Binary files /dev/null and b/beep.wav differ diff --git a/bell-iPad.png b/bell-iPad.png new file mode 100644 index 0000000..dcde767 Binary files /dev/null and b/bell-iPad.png differ diff --git a/bell.png b/bell.png new file mode 100644 index 0000000..7dcb473 Binary files /dev/null and b/bell.png differ diff --git a/blackGlass.png b/blackGlass.png new file mode 100644 index 0000000..cbac083 Binary files /dev/null and b/blackGlass.png differ diff --git a/blackScreen.png b/blackScreen.png new file mode 100644 index 0000000..491c3c4 Binary files /dev/null and b/blackScreen.png differ diff --git a/blueTrack.png b/blueTrack.png new file mode 100644 index 0000000..dc059e9 Binary files /dev/null and b/blueTrack.png differ diff --git a/clockIcon.png b/clockIcon.png new file mode 100644 index 0000000..9990db9 Binary files /dev/null and b/clockIcon.png differ diff --git a/clockView-iPad.png b/clockView-iPad.png new file mode 100644 index 0000000..ce99035 Binary files /dev/null and b/clockView-iPad.png differ diff --git a/currentLocation.png b/currentLocation.png new file mode 100644 index 0000000..a4ba642 Binary files /dev/null and b/currentLocation.png differ diff --git a/currentLocationGlowing.png b/currentLocationGlowing.png new file mode 100644 index 0000000..421b977 Binary files /dev/null and b/currentLocationGlowing.png differ diff --git a/digital-7 (italic).ttf b/digital-7 (italic).ttf new file mode 100755 index 0000000..c120ab4 Binary files /dev/null and b/digital-7 (italic).ttf differ diff --git a/digital-7.ttf b/digital-7.ttf new file mode 100755 index 0000000..e51060b Binary files /dev/null and b/digital-7.ttf differ diff --git a/disclosure-iPad.png b/disclosure-iPad.png new file mode 100644 index 0000000..23d0b2b Binary files /dev/null and b/disclosure-iPad.png differ diff --git a/dynamite.png b/dynamite.png new file mode 100644 index 0000000..e0acd27 Binary files /dev/null and b/dynamite.png differ diff --git a/explosion.mp3 b/explosion.mp3 new file mode 100644 index 0000000..8b20a9b Binary files /dev/null and b/explosion.mp3 differ diff --git a/fastForward.png b/fastForward.png new file mode 100644 index 0000000..8de18c2 Binary files /dev/null and b/fastForward.png differ diff --git a/findLine.png b/findLine.png new file mode 100644 index 0000000..6d78a12 Binary files /dev/null and b/findLine.png differ diff --git a/hourGlassIcon.png b/hourGlassIcon.png new file mode 100644 index 0000000..b62d111 Binary files /dev/null and b/hourGlassIcon.png differ diff --git a/indicatorLightOff-iPad.png b/indicatorLightOff-iPad.png new file mode 100644 index 0000000..ae7ec77 Binary files /dev/null and b/indicatorLightOff-iPad.png differ diff --git a/indicatorLightOn-iPad.png b/indicatorLightOn-iPad.png new file mode 100644 index 0000000..444710f Binary files /dev/null and b/indicatorLightOn-iPad.png differ diff --git a/info.png b/info.png new file mode 100644 index 0000000..5450ce3 Binary files /dev/null and b/info.png differ diff --git a/info@2x.png b/info@2x.png new file mode 100644 index 0000000..65e564e Binary files /dev/null and b/info@2x.png differ diff --git a/keypadBackground.png b/keypadBackground.png new file mode 100644 index 0000000..4b8228a Binary files /dev/null and b/keypadBackground.png differ diff --git a/lightRow.png b/lightRow.png new file mode 100644 index 0000000..c39ea51 Binary files /dev/null and b/lightRow.png differ diff --git a/lightRowTop.png b/lightRowTop.png new file mode 100644 index 0000000..5919078 Binary files /dev/null and b/lightRowTop.png differ diff --git a/lightTexturedBackground.png b/lightTexturedBackground.png new file mode 100644 index 0000000..184e9e0 Binary files /dev/null and b/lightTexturedBackground.png differ diff --git a/main.m b/main.m new file mode 100644 index 0000000..c5674f5 --- /dev/null +++ b/main.m @@ -0,0 +1,17 @@ +// +// main.m +// Sleep Blaster touch +// +// Created by Eamon Ford on 6/9/09. +// Copyright The Byte Factory 2009. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + int retVal = UIApplicationMain(argc, argv, nil, nil); + [pool release]; + return retVal; +} + diff --git a/mapBottomBar.png b/mapBottomBar.png new file mode 100644 index 0000000..0e931aa Binary files /dev/null and b/mapBottomBar.png differ diff --git a/noSound.wav b/noSound.wav new file mode 100644 index 0000000..9fbce37 Binary files /dev/null and b/noSound.wav differ diff --git a/numericBlueButton.png b/numericBlueButton.png new file mode 100644 index 0000000..4bb8ed5 Binary files /dev/null and b/numericBlueButton.png differ diff --git a/numericBlueButtonPressed.png b/numericBlueButtonPressed.png new file mode 100644 index 0000000..5c1ad83 Binary files /dev/null and b/numericBlueButtonPressed.png differ diff --git a/numericButton.png b/numericButton.png new file mode 100644 index 0000000..9436ec7 Binary files /dev/null and b/numericButton.png differ diff --git a/numericButtonPressed.png b/numericButtonPressed.png new file mode 100644 index 0000000..9d7d692 Binary files /dev/null and b/numericButtonPressed.png differ diff --git a/numericRedButton.png b/numericRedButton.png new file mode 100644 index 0000000..186f429 Binary files /dev/null and b/numericRedButton.png differ diff --git a/numericRedButtonPressed.png b/numericRedButtonPressed.png new file mode 100644 index 0000000..ab386fd Binary files /dev/null and b/numericRedButtonPressed.png differ diff --git a/pinkNoise.m4a b/pinkNoise.m4a new file mode 100644 index 0000000..3a1e449 Binary files /dev/null and b/pinkNoise.m4a differ diff --git a/redDrawButton.png b/redDrawButton.png new file mode 100644 index 0000000..9d09a1f Binary files /dev/null and b/redDrawButton.png differ diff --git a/redDrawButtonPressed.png b/redDrawButtonPressed.png new file mode 100644 index 0000000..5119cec Binary files /dev/null and b/redDrawButtonPressed.png differ diff --git a/rewind.png b/rewind.png new file mode 100644 index 0000000..318d4d6 Binary files /dev/null and b/rewind.png differ diff --git a/segmentedControlMusicDeselected.png b/segmentedControlMusicDeselected.png new file mode 100644 index 0000000..b837e90 Binary files /dev/null and b/segmentedControlMusicDeselected.png differ diff --git a/segmentedControlMusicSelected.png b/segmentedControlMusicSelected.png new file mode 100644 index 0000000..57d611a Binary files /dev/null and b/segmentedControlMusicSelected.png differ diff --git a/segmentedControlOceanWavesDeselected.png b/segmentedControlOceanWavesDeselected.png new file mode 100644 index 0000000..407e5b2 Binary files /dev/null and b/segmentedControlOceanWavesDeselected.png differ diff --git a/segmentedControlOceanWavesSelected.png b/segmentedControlOceanWavesSelected.png new file mode 100644 index 0000000..048a76f Binary files /dev/null and b/segmentedControlOceanWavesSelected.png differ diff --git a/segmentedControlPlaceDeselected.png b/segmentedControlPlaceDeselected.png new file mode 100644 index 0000000..8068a69 Binary files /dev/null and b/segmentedControlPlaceDeselected.png differ diff --git a/segmentedControlPlaceSelected.png b/segmentedControlPlaceSelected.png new file mode 100644 index 0000000..ba03111 Binary files /dev/null and b/segmentedControlPlaceSelected.png differ diff --git a/segmentedControlSnooze.png b/segmentedControlSnooze.png new file mode 100644 index 0000000..0472de6 Binary files /dev/null and b/segmentedControlSnooze.png differ diff --git a/segmentedControlSnoozeSelected.png b/segmentedControlSnoozeSelected.png new file mode 100644 index 0000000..82f70e2 Binary files /dev/null and b/segmentedControlSnoozeSelected.png differ diff --git a/segmentedControlStop.png b/segmentedControlStop.png new file mode 100644 index 0000000..adc44ce Binary files /dev/null and b/segmentedControlStop.png differ diff --git a/segmentedControlStopSelected.png b/segmentedControlStopSelected.png new file mode 100644 index 0000000..1dd821d Binary files /dev/null and b/segmentedControlStopSelected.png differ diff --git a/segmentedControlTimeDeselected.png b/segmentedControlTimeDeselected.png new file mode 100644 index 0000000..46b8228 Binary files /dev/null and b/segmentedControlTimeDeselected.png differ diff --git a/segmentedControlTimeSelected.png b/segmentedControlTimeSelected.png new file mode 100644 index 0000000..1b693cb Binary files /dev/null and b/segmentedControlTimeSelected.png differ diff --git a/silent.mp3 b/silent.mp3 new file mode 100644 index 0000000..a3b8f92 Binary files /dev/null and b/silent.mp3 differ diff --git a/sleepTimerButton.png b/sleepTimerButton.png new file mode 100644 index 0000000..900591e Binary files /dev/null and b/sleepTimerButton.png differ diff --git a/snoozeButton.png b/snoozeButton.png new file mode 100644 index 0000000..bf34320 Binary files /dev/null and b/snoozeButton.png differ diff --git a/stopSleepTimerButton.png b/stopSleepTimerButton.png new file mode 100644 index 0000000..d1c5876 Binary files /dev/null and b/stopSleepTimerButton.png differ diff --git a/switch_lighter.png b/switch_lighter.png new file mode 100644 index 0000000..4263774 Binary files /dev/null and b/switch_lighter.png differ diff --git a/switch_off_lighter.png b/switch_off_lighter.png new file mode 100644 index 0000000..4e4865f Binary files /dev/null and b/switch_off_lighter.png differ diff --git a/switch_on_lighter.png b/switch_on_lighter.png new file mode 100644 index 0000000..e8882c8 Binary files /dev/null and b/switch_on_lighter.png differ diff --git a/translucentScreen.png b/translucentScreen.png new file mode 100644 index 0000000..2438e26 Binary files /dev/null and b/translucentScreen.png differ diff --git a/whiteSlide.png b/whiteSlide.png new file mode 100644 index 0000000..32b810a Binary files /dev/null and b/whiteSlide.png differ diff --git a/whiteTrack.png b/whiteTrack.png new file mode 100644 index 0000000..a2edb93 Binary files /dev/null and b/whiteTrack.png differ