Created
July 10, 2014 20:56
-
-
Save jontelang/c83728776e84e9b12cb3 to your computer and use it in GitHub Desktop.
as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <math.h> | |
%hook SBAwayController | |
@interface UIApplication () | |
- (id)_accessibilityRunningApplications; | |
@end | |
@interface SBStatusBarDataManager | |
+ (id)sharedDataManager; | |
- (void)enableTime:(BOOL)arg1; | |
@end | |
@interface SBApplicationController | |
+(id)sharedInstanceIfExists; | |
- (id)applicationsWithBundleIdentifier:(id)arg1; | |
- (id)applicationWithDisplayIdentifier:(id)arg1; | |
- (id)allApplications; | |
@end | |
@interface SBUIController | |
- (void)createFakeSpringBoardStatusBar; | |
@end | |
@interface SBApplication | |
@property(readonly, nonatomic) int pid; | |
@property(copy) NSString *displayIdentifier; | |
- (void)notifyResignActiveForReason:(int)arg1; | |
- (void)deactivate; | |
- (id)displayName; | |
- (BOOL)isRunning; | |
- (void)resumeToQuit; | |
- (void)suspend; | |
- (void)kill; | |
@end | |
@interface SBAwayController <UIGestureRecognizerDelegate> | |
+(id)sharedAwayController; | |
-(BOOL)isDimmed; | |
-(NSString*)getTime:(double)elapsedSeconds; | |
-(void)startThatTimer; | |
-(BOOL)isShowingMediaControls; | |
-(BOOL)undimsDisplay; | |
-(BOOL)shouldShowLockStatusBarTime; | |
-(void)removeAwayViewFakeStatusBar; | |
-(void)updateInterfaceIfNecessary; | |
-(void)undimScreen; | |
-(BOOL)isLockedAndUndimmed; | |
-(void)IncreaseSeconds; | |
- (void)hideMediaControls; | |
-(void)toggleOn:(id)arg1; | |
-(void)saveStopWatch; | |
-(void)actuallyStartThatTimer; | |
-(void)turnOff:(id)arg1; | |
- (void)_dismissShowcase; | |
-(void)didAnimateLockKeypadOut; | |
- (void)activate; | |
- (void)deactivate; | |
@end | |
@interface SBAwayView : UIView | |
- (void)updateInterface; | |
@end | |
@interface SBAwayDateView : UIView | |
-(void)updateClock; | |
-(void)update; | |
@end | |
@interface TPLCDTextView : UIView | |
-(void)setText:(id)arg; | |
-(id)text; | |
-(void)setCenterText:(CGRect)arg; | |
-(id)textRect; | |
-(void)setFrame:(CGRect)frame; | |
-(void)setFont:(id)font; | |
@end | |
static TPLCDTextView* labelClock = Nil; | |
static TPLCDTextView *labelDate = Nil; | |
static UILabel* panelLabel = Nil; | |
static double totalSeconds; | |
static double totalLAPseconds; | |
static double lastTime; | |
static NSTimer* timer = Nil; | |
static int fontSize = 67; | |
static NSString* statusText = @""; | |
static BOOL replacesClock = FALSE; | |
static BOOL hasPanel = FALSE; | |
static BOOL isPaused = FALSE; | |
static BOOL isEnabled = TRUE; | |
static BOOL stopwatchIsRunning = FALSE; | |
static BOOL force = 1; | |
static int (*BKSTerminateApplicationForReasonAndReportWithDescription)(NSString *displayIdentifier, int reason, int something, int something2); | |
void *bk = dlopen("/System/Library/PrivateFrameworks/BackBoardServices.framework/BackBoardServices", RTLD_LAZY); | |
%new | |
-(NSString*)getTime:(double)elapsedSeconds | |
{ | |
// Round like the clock.app | |
// 1.299999 = 1.2 | |
elapsedSeconds = elapsedSeconds * 10.0; | |
elapsedSeconds = (int)elapsedSeconds; | |
elapsedSeconds = elapsedSeconds / 10.0; | |
NSUInteger h = (int)elapsedSeconds / 3600; | |
NSUInteger m = ((int)elapsedSeconds / 60) % 60; | |
NSUInteger s = (int)elapsedSeconds % 60; | |
double ms = elapsedSeconds - (double)((int)elapsedSeconds); | |
double sandms = s+ms; | |
NSString *formattedTime = [NSString stringWithFormat:@"%02u:%04.1f", m, sandms]; | |
if(h > 0) | |
{ | |
formattedTime = [NSString stringWithFormat:@"%02u:%@",h,formattedTime]; | |
} | |
return formattedTime; | |
} | |
%new | |
-(void)IncreaseSeconds | |
{ | |
// | |
// Maybe here should be something better to MAKE SURE the labels and shit gets gone. | |
// Maybe an "reset all" methid that gets called on more places | |
// | |
//if( !timer ) return; | |
BOOL active = MSHookIvar<BOOL>(self, "_isActive"); | |
if( active ) | |
{ | |
SBAwayView* sbav = MSHookIvar<SBAwayView *>(self, "_awayView"); | |
SBAwayDateView* sbadv = MSHookIvar<SBAwayDateView *>(sbav, "_dateHeaderView"); | |
labelClock = MSHookIvar<TPLCDTextView *>(sbadv, "_timeLabel"); | |
labelDate = MSHookIvar<TPLCDTextView *>(sbadv, "_dateAndTetheringLabel"); | |
if( replacesClock && ![statusText isEqual:@""] ) | |
{ | |
[labelDate setText:statusText]; | |
} | |
//NSLog(@"BEFORE totalSeconds: %f lastTime: %f", totalSeconds, lastTime); | |
totalSeconds += 0.1; | |
lastTime += 0.1; // Just for later saving | |
//NSLog(@"AFTER totalSeconds: %f lastTime: %f", totalSeconds, lastTime); | |
if( replacesClock && hasPanel ) | |
{ | |
// Move setfont to startThatTimer @TODO | |
[labelClock setFont:[UIFont systemFontOfSize:fontSize]]; | |
[labelClock setText:[self getTime:totalSeconds]]; | |
NSDateFormatter *DateFormatter = [[NSDateFormatter alloc] init]; | |
[DateFormatter setDateFormat:@"hh:mm"]; | |
NSString *currentTime = [DateFormatter stringFromDate:[NSDate date]]; | |
[panelLabel setText:currentTime]; | |
} | |
else if( replacesClock ) | |
{ | |
// Move setfont to startThatTimer @TODO | |
[labelClock setFont:[UIFont systemFontOfSize:fontSize]]; | |
[labelClock setText:[self getTime:totalSeconds]]; | |
} | |
else if( hasPanel ) | |
{ | |
[panelLabel setText:[self getTime:totalSeconds]]; | |
} | |
} | |
else | |
{ | |
//NSLog(@"Invalidating timer"); | |
[timer invalidate]; | |
timer = Nil; | |
panelLabel = Nil; | |
labelClock = Nil; | |
labelDate = Nil; | |
//[self saveStopWatch]; | |
//NSLog(@" Panellabel = NIL"); | |
} | |
} | |
%new | |
- (void)toggleOn:(UITapGestureRecognizer *)recognizer | |
{ | |
//NSLog(@"----- SBAwayController : toggleOn (tapped) : BEGIN -----"); | |
//[timer invalidate]; | |
//timer = Nil; | |
NSMutableDictionary *clockPrefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.apple.mobiletimer.plist"]; | |
if( clockPrefs ) | |
{ | |
////NSLog(@"%@",clockPrefs); | |
BOOL isRunning = [[clockPrefs valueForKey:@"TIMERRUNNING"] boolValue]; | |
if(isRunning) | |
{ | |
//NSLog(@"Stopping"); | |
[timer invalidate]; | |
timer = Nil; | |
[clockPrefs removeObjectForKey:@"STARTTIME"]; | |
statusText = @"Stopped"; | |
isPaused = TRUE; | |
} | |
else | |
{ | |
//NSLog(@"Starting"); | |
[clockPrefs setValue:[NSDate date] forKey:@"STARTTIME"]; | |
} | |
[clockPrefs setValue:[NSNumber numberWithBool:!isRunning] forKey:@"TIMERRUNNING"]; | |
[clockPrefs setValue:[NSNumber numberWithDouble:totalSeconds-totalLAPseconds] forKey:@"OFFSET"]; | |
[clockPrefs setValue:[NSNumber numberWithDouble:totalSeconds-totalLAPseconds] forKey:@"LASTTIME"]; | |
[clockPrefs writeToFile:@"/var/mobile/Library/Preferences/com.apple.mobiletimer.plist" atomically:YES]; | |
if( !isRunning ) | |
[self actuallyStartThatTimer]; | |
////NSLog(@"%@",clockPrefs); | |
} | |
//SBApplicationController* s = [%c(SBApplicationController) sharedInstanceIfExists]; | |
//SBApplication *a = [s applicationWithDisplayIdentifier:@"com.apple.mobiletimer"]; | |
////NSLog(@"%@",a); | |
//if( [a isRunning] ) | |
//{ | |
BKSTerminateApplicationForReasonAndReportWithDescription = (int (*)(NSString*, int, int, int))dlsym(bk, "BKSTerminateApplicationForReasonAndReportWithDescription"); | |
BKSTerminateApplicationForReasonAndReportWithDescription(@"com.apple.mobiletimer", 1, 0, 0); | |
/* | |
int pid = [a pid]; | |
//NSLog(@"pid: %i", pid); | |
NSString *cmd = [NSString stringWithFormat:@"kill %i",pid]; | |
//NSLog(@"%@",cmd); | |
const char *command = [cmd UTF8String]; | |
//NSLog(@"%s",command); | |
int result = system(command); | |
//NSLog(@"%i",result); | |
*/ | |
//} | |
if( replacesClock ) | |
[labelDate setText:statusText]; | |
//NSLog(@"----- SBAwayController : toggleOn (tapped) : END -----"); | |
} | |
%new | |
-(void)actuallyStartThatTimer | |
{ | |
if( !timer ) | |
{ | |
stopwatchIsRunning = TRUE; | |
force = 0; | |
[self _dismissShowcase]; | |
statusText = @"Stopwatch"; | |
timer = [NSTimer scheduledTimerWithTimeInterval:0.1 | |
target:self | |
selector:@selector(IncreaseSeconds) | |
userInfo:nil | |
repeats:YES]; | |
force = 1; | |
} | |
} | |
%new | |
-(void)turnOff:(UITapGestureRecognizer *)recognizer | |
{ | |
//NSLog(@"----- SBAwayController : TURN OFF (tapped) : BEGIN -----"); | |
[timer invalidate]; | |
timer = Nil; | |
[panelLabel removeFromSuperview]; | |
panelLabel = Nil; | |
NSMutableDictionary *clockPrefs = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.apple.mobiletimer.plist"]; | |
if( clockPrefs ) | |
{ | |
[clockPrefs removeObjectForKey:@"STARTTIME"]; | |
[clockPrefs setValue:[NSNumber numberWithBool:FALSE] forKey:@"TIMERRUNNING"]; | |
[clockPrefs removeObjectForKey:@"LAPS"]; | |
[clockPrefs setValue:[NSNumber numberWithDouble:0] forKey:@"OFFSET"]; | |
[clockPrefs setValue:[NSNumber numberWithDouble:0] forKey:@"LASTTIME"]; | |
[clockPrefs writeToFile:@"/var/mobile/Library/Preferences/com.apple.mobiletimer.plist" atomically:YES]; | |
} | |
BKSTerminateApplicationForReasonAndReportWithDescription = (int (*)(NSString*, int, int, int))dlsym(bk, "BKSTerminateApplicationForReasonAndReportWithDescription"); | |
BKSTerminateApplicationForReasonAndReportWithDescription(@"com.apple.mobiletimer", 1, 0, 0); | |
totalSeconds = 0; | |
lastTime = 0; | |
totalLAPseconds = 0; | |
SBAwayView* sbav = MSHookIvar<SBAwayView *>(self, "_awayView"); | |
SBAwayDateView* sbadv = MSHookIvar<SBAwayDateView *>(sbav, "_dateHeaderView"); | |
//[self startThatTimer]; | |
//[self didAnimateLockKeypadOut]; | |
//isEnabled = FALSE;//justto get through the check. | |
//[self updateInterfaceIfNecessary]; | |
//[sbav updateInterface]; | |
if(![self shouldShowLockStatusBarTime]) | |
{ | |
//NSLog(@"self shouldShowLockStatusBarTime should be 0 and make force 1"); | |
force = 0; | |
[self _dismissShowcase]; | |
[sbadv updateClock]; | |
//[sbadv update]; | |
force = 1; | |
} | |
if( hasPanel ) | |
{ | |
[panelLabel removeFromSuperview]; | |
panelLabel = Nil; | |
} | |
// [self hideMediaControls]; | |
// [self deactivate]; | |
//[self activate]; | |
///NSString *MSHookIvar<NSString*>(s,"") | |
////NSLog(@"SHOULE DISABLE TIME"); | |
//SBStatusBarDataManager *s = [%c(sharedDataManager) sharedDataManager]; | |
////NSLog(@"%@",s); | |
//[s enableTime:FALSE]; | |
////NSLog(@"SHOULEVE DISABLED TIME"); | |
//[self setNeedsLayout]; | |
//NSLog(@"----- SBAwayController : TURN OFF (tapped) : END -----"); | |
} | |
%new | |
-(void)startThatTimer | |
{ | |
//NSLog(@"----- SBAwayController : startThatTimer : BEGIN -----"); | |
// Delete the timer. | |
if( timer ) | |
{ | |
if( [timer isValid] ) | |
{ | |
//NSLog(@"----- SBAwayController : startThatTimer : END 1 -----"); | |
return; | |
//[timer invalidate]; | |
//timer = Nil; | |
} | |
} | |
// Reset | |
lastTime = 0; | |
totalSeconds = 0; | |
totalLAPseconds = 0; | |
replacesClock = FALSE; | |
hasPanel = FALSE; | |
//isEnabled = FALSE; | |
statusText = @""; | |
// Grab things | |
SBAwayView* sbav = MSHookIvar<SBAwayView *>(self, "_awayView"); | |
if(!sbav) | |
{ | |
//NSLog(@"sbav nil"); | |
//NSLog(@"----- SBAwayController : startThatTimer : END 2 -----"); | |
return; | |
} | |
SBAwayDateView* sbadv = MSHookIvar<SBAwayDateView *>(sbav, "_dateHeaderView"); | |
if(!sbadv) | |
{ | |
//labelClock = Nil; | |
panelLabel = Nil; | |
//NSLog(@"sbadv nil"); | |
//NSLog(@"----- SBAwayController : startThatTimer : END 3 -----"); | |
return; | |
} | |
labelClock = MSHookIvar<TPLCDTextView *>(sbadv, "_timeLabel"); | |
labelDate = MSHookIvar<TPLCDTextView *>(sbadv, "_dateAndTetheringLabel"); | |
// If there is a preference-file | |
NSDictionary *prefsfile = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.jontelang.stoppur.plist"]; | |
if( prefsfile ) | |
{ | |
replacesClock = [[prefsfile valueForKey:@"replacesClock"] boolValue]; | |
hasPanel = [[prefsfile valueForKey:@"hasPanel"] boolValue]; | |
isEnabled = [[prefsfile valueForKey:@"isEnabled"] boolValue]; | |
if( isEnabled && (hasPanel || replacesClock) ) | |
{ | |
NSDictionary *clockPrefs = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.apple.mobiletimer.plist"]; | |
if( clockPrefs ) | |
{ | |
stopwatchIsRunning = [[clockPrefs valueForKey:@"TIMERRUNNING"] boolValue]; | |
NSDate *startTime = [clockPrefs valueForKey:@"STARTTIME"]; | |
NSTimeInterval timeInterval = [startTime timeIntervalSinceNow]; | |
lastTime = [[clockPrefs valueForKey:@"LASTTIME"] doubleValue]; | |
totalSeconds = -(double)timeInterval + lastTime; | |
BOOL showsTotalTime = [[prefsfile valueForKey:@"showsTotalTime"] boolValue]; | |
if( showsTotalTime ) | |
{ | |
//NSLog(@"Shows total time (add laps if any)"); | |
NSArray *laps = [clockPrefs valueForKey:@"LAPS"]; | |
if( laps ) | |
{ | |
for (uint i = 0; i < [laps count]; i++) | |
{ | |
totalLAPseconds += [[laps objectAtIndex:i] doubleValue]; | |
} | |
} | |
//lastTime = totalSeconds;// + (lastTime-(int)lastTime); // Orkar inte.. | |
} | |
totalSeconds += totalLAPseconds; | |
//NSLog(@" "); | |
//NSLog(@"loaded totalSeconds: %f", totalSeconds); | |
//NSLog(@"loaded lastTime: %f", lastTime); | |
//NSLog(@" "); | |
isPaused = (lastTime > 0) && (stopwatchIsRunning == FALSE); | |
// If it "is Paused" we set the labels anyway. | |
NSString *setPanelTextToThis = @"00:00:00.0"; | |
if( replacesClock && hasPanel && isPaused ) | |
{ | |
//NSLog(@"Both"); | |
[labelClock setFont:[UIFont systemFontOfSize:fontSize]]; | |
[labelClock setText:[self getTime:totalSeconds]]; | |
NSDateFormatter *DateFormatter = [[NSDateFormatter alloc] init]; | |
[DateFormatter setDateFormat:@"hh:mm"]; | |
NSString *currentTime = [DateFormatter stringFromDate:[NSDate date]]; | |
setPanelTextToThis = currentTime; | |
} | |
else if( replacesClock && isPaused ) | |
{ | |
//NSLog(@"Only replacesClock"); | |
[labelClock setText:[self getTime:totalSeconds]]; | |
} | |
else if( hasPanel && isPaused ) | |
{ | |
//NSLog(@"Only hasPanel"); | |
setPanelTextToThis = [self getTime:totalSeconds]; | |
} | |
//NSLog(@" CREATE PANEL ??? "); | |
//NSLog(@"( %i || %i ) && %i", hasPanel, isPaused, !panelLabel); | |
if( (hasPanel || isPaused) && !panelLabel ) | |
{ | |
//NSLog(@"Creating panel"); | |
int x = 50; // Defaults | |
int y = 97; | |
int fontSizePanel = 20; | |
int panel_x = [[prefsfile valueForKey:@"panel_x"] intValue]; | |
if( panel_x ) x = panel_x; | |
int panel_y = [[prefsfile valueForKey:@"panel_y"] intValue]; | |
if( panel_y ) y = panel_y; | |
int panel_font_size = [[prefsfile valueForKey:@"panel_font_size"] intValue]; | |
if( panel_font_size ) fontSizePanel = panel_font_size; | |
if( panelLabel ) | |
{ | |
//NSLog(@"Remove old panel"); | |
[panelLabel removeFromSuperview]; | |
panelLabel = Nil; | |
} | |
//NSLog(@"setPanelTextToThis: %@", setPanelTextToThis); | |
CGSize size = [setPanelTextToThis sizeWithFont:[UIFont systemFontOfSize:fontSizePanel]]; | |
if( [setPanelTextToThis isEqual:@"00:00:00.0"] ){setPanelTextToThis=@"";} | |
CGRect frame = CGRectMake(0,0,size.width*1.5,size.height); | |
panelLabel = [[UILabel alloc] initWithFrame:frame]; | |
panelLabel.backgroundColor = [UIColor clearColor]; | |
panelLabel.textColor = [UIColor whiteColor]; | |
panelLabel.shadowColor = [UIColor blackColor]; | |
panelLabel.shadowOffset = CGSizeMake(0.0, 1.0); | |
panelLabel.textAlignment = UITextAlignmentCenter; | |
panelLabel.layer.borderWidth = 0; | |
[panelLabel setFont:[UIFont systemFontOfSize:fontSizePanel]]; | |
[panelLabel setCenter:CGPointMake(x,y)]; | |
panelLabel.userInteractionEnabled = YES; | |
[panelLabel setText:setPanelTextToThis]; | |
//[panelLabel setText:[NSString stringWithFormat:@"%@",size]]; | |
[sbav addSubview:panelLabel]; | |
} | |
/// this should not have its own section | |
//if( replacesClock ) | |
//{ | |
//NSLog(@"Adding gesture recogniser to labelclock"); | |
labelClock.userInteractionEnabled = YES; | |
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleOn:)]; | |
[labelClock addGestureRecognizer:singleTap]; | |
[singleTap release]; | |
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(turnOff:)]; | |
[labelClock addGestureRecognizer:longPress]; | |
[longPress release]; | |
//} | |
//else if( hasPanel ) | |
//{ | |
//NSLog(@"Adding gesture recogniser to panelLabel"); | |
UITapGestureRecognizer *singleTap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleOn:)]; | |
[panelLabel addGestureRecognizer:singleTap2]; | |
[singleTap2 release]; | |
UILongPressGestureRecognizer *longPress2 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(turnOff:)]; | |
[panelLabel addGestureRecognizer:longPress2]; | |
[longPress2 release]; | |
//} | |
/// | |
if( stopwatchIsRunning ) | |
{ | |
//NSLog(@"force = %i (!0 == fire timer)", force); | |
if( force != 0 ) | |
{ | |
//NSLog(@"Fire the timer"); | |
[self actuallyStartThatTimer]; | |
//force = 1; | |
//[self _dismissShowcase]; | |
//force = 0; | |
} | |
} | |
else if( isPaused ) | |
{ | |
statusText = @"Stopped"; | |
} | |
if( replacesClock && ![statusText isEqual:@""] ) | |
{ | |
[labelDate setText:statusText]; | |
} | |
} | |
} | |
else | |
{ | |
//isEnabled = FALSE; | |
} | |
} | |
//NSLog(@"----- SBAwayController : startThatTimer : END 4 -----"); | |
} | |
- (void)_sendToDeviceLockOwnerDeviceUnlockSucceeded | |
{ | |
//NSLog(@"----- SBAwayController : _sendToDeviceLockOwnerDeviceUnlockSucceeded : BEGIN -----"); | |
[panelLabel removeFromSuperview]; | |
panelLabel = Nil; | |
////NSLog(@"panelLabel: %@", panelLabel); | |
%orig; | |
//NSLog(@"----- SBAwayController : _sendToDeviceLockOwnerDeviceUnlockSucceeded : END -----"); | |
} | |
-(void)attemptUnlock | |
{ | |
//NSLog(@"----- SBAwayController : attemptUnlock : BEGIN -----"); | |
[self startThatTimer]; | |
%orig; | |
//NSLog(@"----- SBAwayController : attemptUnlock : END -----"); | |
} | |
-(void)didAnimateLockKeypadIn | |
{ | |
//NSLog(@"----- SBAwayController : didAnimateLockKeypadIn : BEGIN -----"); | |
%orig; | |
if( [self isLockedAndUndimmed] ) | |
{ | |
[self startThatTimer]; | |
if(panelLabel) | |
{ | |
[UIView beginAnimations:nil context:NULL]; | |
[UIView setAnimationDuration:.25]; | |
[panelLabel setAlpha:0]; | |
[UIView commitAnimations]; | |
} | |
} | |
//NSLog(@"----- SBAwayController : didAnimateLockKeypadIn : END -----"); | |
} | |
-(void)didAnimateLockKeypadOut | |
{ | |
//NSLog(@"----- SBAwayController : didAnimateLockKeypadOut : BEGIN -----"); | |
%orig; | |
if( [self isLockedAndUndimmed] ) | |
{ | |
[self startThatTimer]; | |
if(panelLabel) | |
{ | |
[UIView beginAnimations:nil context:NULL]; | |
[UIView setAnimationDuration:.25]; | |
[panelLabel setAlpha:1]; | |
[UIView commitAnimations]; | |
} | |
} | |
//NSLog(@"----- SBAwayController : didAnimateLockKeypadOut : END -----"); | |
} | |
-(BOOL)isShowingMediaControls | |
{ | |
//NSLog(@"----- SBAwayController : isShowingMediaControls : BEGIN -----"); | |
if( [self isLockedAndUndimmed] == FALSE ) | |
{ | |
//NSLog(@"isLockedAndUndimmed == FALSE"); | |
//NSLog(@"----- SBAwayController : isShowingMediaControls : END 1 -----"); | |
return %orig; | |
} | |
BOOL isShowing = %orig; | |
//NSLog(@"orig/isShowing: %i", isShowing); | |
if( isEnabled ) | |
{ | |
////NSLog(@"panelLabel: %@",panelLabel); | |
if( panelLabel ) | |
{ | |
//NSLog(@"Setting panelLabel.hidden to = %i", isShowing); | |
panelLabel.hidden = isShowing; | |
} | |
////NSLog(@"labelClock: %@",labelClock); | |
if( labelClock ) | |
{ | |
//NSLog(@"Setting labelClock.hidden to %i", isShowing); | |
labelClock.hidden = isShowing; | |
} | |
////NSLog(@"labelDate: %@",labelClock); | |
if( labelDate ) | |
{ | |
//NSLog(@"Setting labelDate.hidden to %i", isShowing); | |
labelDate.hidden = isShowing; | |
} | |
} | |
//NSLog(@"----- SBAwayController : isShowingMediaControls : END 2 -----"); | |
return isShowing; | |
} | |
-(BOOL)shouldShowLockStatusBarTime | |
{ | |
//NSLog(@"----- SBAwayController : shouldShowLockStatusBarTime : BEGIN -----"); | |
BOOL original = %orig; | |
if( [self isLockedAndUndimmed] ) | |
{ | |
[self startThatTimer]; | |
} | |
if( isEnabled ) | |
{ | |
//NSLog(@"%i && %i && (%i || %i) || %i", !hasPanel, isEnabled, isPaused, stopwatchIsRunning, original); | |
BOOL actual = (!hasPanel && isEnabled && (isPaused || stopwatchIsRunning)) || original == TRUE; | |
//NSLog(@"Original: %i", original); | |
//NSLog(@"Actual: %i", actual); | |
//NSLog(@"----- SBAwayController : shouldShowLockStatusBarTime : END 1 -----"); | |
return actual; | |
} | |
//NSLog(@"----- SBAwayController : shouldShowLockStatusBarTime : END 2 -----"); | |
return %orig; | |
} | |
//- (void)_dismissShowcase | |
//{ | |
//NSLog(@"----- SBAwayController : _dismissShowcase : BEGIN -----"); | |
//%orig; | |
//NSLog(@"----- SBAwayController : _dismissShowcase : END -----"); | |
//} | |
%end | |
%hook SBAwayDateView | |
//-(void)update | |
//{ | |
//NSLog(@"----- SBAwayDateView : update : BEGIN -----"); | |
//if( isEnabled && (stopwatchIsRunning || isPaused) ) | |
//{ | |
// //NSLog(@"----- SBAwayDateView : update : END 1 -----"); | |
// return; | |
//} | |
//%orig; | |
//NSLog(@"----- SBAwayDateView : update : END 2 -----"); | |
//} | |
-(void)updateClock | |
{ | |
//NSLog(@"----- SBAwayDateView : updateClock : BEGIN -----"); | |
//NSLog(@"%i && (%i || %i)", isEnabled, stopwatchIsRunning, isPaused); | |
if( isEnabled && (stopwatchIsRunning || isPaused) ) | |
{ | |
labelClock = MSHookIvar<TPLCDTextView *>(self, "_timeLabel"); | |
[labelClock setFont:[UIFont systemFontOfSize:fontSize]]; | |
//NSLog(@"%i && %i && %i", replacesClock, hasPanel, (panelLabel != Nil)); | |
if( replacesClock && hasPanel && (panelLabel != Nil)) | |
{ | |
// Just update the label yp | |
NSDateFormatter *DateFormatter = [[NSDateFormatter alloc] init]; | |
[DateFormatter setDateFormat:@"hh:mm"]; | |
NSString *currentTime = [DateFormatter stringFromDate:[NSDate date]]; | |
[panelLabel setText:currentTime]; | |
//NSLog(@"%@",currentTime); | |
//NSLog(@"----- SBAwayDateView : updateClock : END 1 -----"); | |
return; | |
} | |
} | |
%orig; | |
//NSLog(@"----- SBAwayDateView : updateClock : END 2 -----"); | |
} | |
%end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment