Skip to content

Commit 55a82fd

Browse files
committed
Allow user to override automatic idle timer toggling
1 parent c2cf3a7 commit 55a82fd

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Classes/DocSetDownloadManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@
2828

2929
NSDate *_lastUpdated;
3030
BOOL _updatingAvailableDocSetsFromWeb;
31+
32+
BOOL _neverDisableIdleTimer;
3133
}
3234

3335
@property (nonatomic, strong) NSArray *downloadedDocSets;
3436
@property (nonatomic, strong) NSSet *downloadedDocSetNames;
3537
@property (nonatomic, strong) NSArray *availableDownloads;
3638
@property (nonatomic, strong) DocSetDownload *currentDownload;
3739
@property (nonatomic, strong) NSDate *lastUpdated;
40+
@property (nonatomic, assign) BOOL neverDisableIdleTimer;
3841

3942
+ (id)sharedDownloadManager;
4043
- (void)reloadAvailableDocSets;

Classes/DocSetDownloadManager.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ - (void)downloadFailed:(DocSetDownload *)download;
2323

2424
@implementation DocSetDownloadManager
2525

26-
@synthesize downloadedDocSets=_downloadedDocSets, downloadedDocSetNames=_downloadedDocSetNames, availableDownloads=_availableDownloads, currentDownload=_currentDownload, lastUpdated=_lastUpdated;
26+
@synthesize downloadedDocSets=_downloadedDocSets, downloadedDocSetNames=_downloadedDocSetNames, availableDownloads=_availableDownloads, currentDownload=_currentDownload, lastUpdated=_lastUpdated, neverDisableIdleTimer = _neverDisableIdleTimer;
2727

2828
- (id)init
2929
{
@@ -221,14 +221,20 @@ - (void)downloadFailed:(DocSetDownload *)download
221221
- (void)toggleIdleTimerIfNeeded
222222
{
223223
BOOL shouldDisableIdleTimer = NO;
224-
if (self.currentDownload) {
224+
if (self.currentDownload && !self.neverDisableIdleTimer) {
225225
shouldDisableIdleTimer = YES;
226226
}
227227

228228
[[UIApplication sharedApplication] setIdleTimerDisabled:shouldDisableIdleTimer];
229229
[[NSNotificationCenter defaultCenter] postNotificationName:DocSetDownloadManagerIdleTimerToggledNotification object:self];
230230
}
231231

232+
- (void)setNeverDisableIdleTimer:(BOOL)neverDisableIdleTimer
233+
{
234+
_neverDisableIdleTimer = neverDisableIdleTimer;
235+
[self toggleIdleTimerIfNeeded];
236+
}
237+
232238
@end
233239

234240

Classes/DownloadViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ - (void)done:(id)sender
9696

9797
- (void)disableIdleTimerSwitchToggled:(id)sender
9898
{
99+
[[DocSetDownloadManager sharedDownloadManager] setNeverDisableIdleTimer:!self.disableIdleTimerSwitch.on];
99100
}
100101

101102
- (void)idleTimerToggled:(NSNotification *)notification

0 commit comments

Comments
 (0)