Skip to content

Commit

Permalink
Work at getting more intelligent alert dismiss. Doesn't work yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhajas committed Apr 16, 2011
1 parent 3f10ac1 commit 73a07d4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
4 changes: 4 additions & 0 deletions MNAlertManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-(void)hidePendingAlert;
-(void)reloadPreferences;

-(void)refreshAll;
-(void)removeAllPendingAlertsWithSender:(NSString *)sender;
-(void)takeActionOnAlertWithData:(MNAlertData *)data;

-(void)clearPending;
-(void)alertShouldGoLaterTimerFired:(id)sender;

Expand Down
44 changes: 30 additions & 14 deletions MNAlertManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -217,29 +217,46 @@ -(void)alertViewController:(MNAlertViewController *)viewController hadActionTake
alertIsShowing = NO;
MNAlertData *data = viewController.dataObj;

//Launch the bundle
[_delegate launchAppInSpringBoardWithBundleID:data.bundleID];
//Move alert into dismissedAlerts from pendingAlerts
[dismissedAlerts addObject:data];
[pendingAlerts removeObject:data];
[self takeActionOnAlertWithData:data];
}
alertWindow.frame = CGRectMake(0,20,320,0);
[self saveOut];
[dashboard refresh];
[lockscreen refresh];
}

-(void)takeActionOnAlertWithData:(MNAlertData *)data
{
//Launch the bundle
[_delegate launchAppInSpringBoardWithBundleID:data.bundleID];
//Move alert into dismissed alerts from either pendingAlerts or sentAwayAlerts
[dismissedAlerts addObject:data];
[pendingAlerts removeObject:data];
[self removeAllPendingAlertsWithSender:data.header];

//Cool! All done!
}

-(void)removeAllPendingAlertsWithSender:(NSString *)sender
{
//Loop through all pending alerts, and remove all the ones that are from the same sender

NSMutableArray *toRemove = [NSMutableArray array];

for(MNAlertData* dataObj in pendingAlerts)
{
if(dataObj.header == sender)
{
[dismissedAlerts addObject:dataObj];
[toRemove addObject:dataObj];
}
}

[pendingAlerts removeObjectsInArray:toRemove];

[self saveOut];
[self refreshAll];
}

-(void)refreshAll
{
[dashboard refresh];
[lockscreen refresh];
//Cool! All done!
}

-(UIImage*)iconForBundleID:(NSString *)bundleID;
Expand Down Expand Up @@ -303,8 +320,7 @@ -(void)clearPending
[pendingAlerts removeObject:dataObj];
}
[self saveOut];
[dashboard refresh];
[lockscreen refresh];
[self refreshAll];
}

-(void)alertShouldGoLaterTimerFired:(id)sender
Expand Down Expand Up @@ -346,7 +362,7 @@ -(void)dismissSwitcher

-(void)wakeDeviceScreen
{
[lockscreen refresh];
[self refreshAll];
[_delegate wakeDeviceScreen];
}

Expand Down

0 comments on commit 73a07d4

Please sign in to comment.