*Added an option to add estimated time to the exact time. Example: "48m ago • 09:41" *Added an option to add minutes to "Xh ago" Example: "5h 47m ago" *You can also combine these two options to get something like this: "5h 47m ago • 09:41" *Added an icon to the preferences.beta-future-time
after-install:: | after-install:: | ||||
install.exec "killall -9 SpringBoard" | install.exec "killall -9 SpringBoard" | ||||
SUBPROJECTS += exacttimeprefs | |||||
include $(THEOS_MAKE_PATH)/aggregate.mk |
@end | @end | ||||
static bool is24h; | static bool is24h; | ||||
static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist"; | |||||
%hook NCLookHeaderContentView | %hook NCLookHeaderContentView | ||||
-(void)_updateDateLabelFontForShortLook{ | -(void)_updateDateLabelFontForShortLook{ | ||||
%orig; | %orig; | ||||
NSDate *date = MSHookIvar<NSDate *>(self, "_date"); | NSDate *date = MSHookIvar<NSDate *>(self, "_date"); | ||||
NSInteger format = MSHookIvar<NSInteger >(self, "_dateFormatStyle"); | NSInteger format = MSHookIvar<NSInteger >(self, "_dateFormatStyle"); | ||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath]; | |||||
CGFloat affectTime = [[prefs objectForKey:@"affectTime"] floatValue]; | |||||
if((date != nil) && (format == 1)){ | if((date != nil) && (format == 1)){ | ||||
NCNotificationDateLabel *dateLabel = MSHookIvar<NCNotificationDateLabel *>(self, "_dateLabel"); | NCNotificationDateLabel *dateLabel = MSHookIvar<NCNotificationDateLabel *>(self, "_dateLabel"); | ||||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | |||||
if(is24h) | |||||
{ | |||||
[dateFormatter setDateFormat:@"HH:mm"]; | |||||
}else{ | |||||
[dateFormatter setDateFormat:@"h:mm a"]; | |||||
int timeSinceNow = (int)[date timeIntervalSinceNow]; | |||||
timeSinceNow = timeSinceNow*-1; | |||||
bool addMinutes = [[prefs objectForKey:@"addMinutes"] boolValue]; | |||||
bool addToCurrent = [[prefs objectForKey:@"addToCurrent"] boolValue]; | |||||
int hours = timeSinceNow / 3600; | |||||
int minutes = (timeSinceNow % 3600) / 60; | |||||
if(addMinutes){ | |||||
if(hours == 0){ | |||||
if(minutes == 0){ | |||||
}else{ | |||||
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes]; | |||||
} | |||||
}else{ | |||||
if(minutes == 0){ | |||||
dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours]; | |||||
} else{ | |||||
dateLabel.text = [NSString stringWithFormat:@"%ih %im ago", hours, minutes]; | |||||
} | |||||
} | |||||
}else if(addToCurrent){ | |||||
if(hours == 0){ | |||||
if(minutes == 0){ | |||||
}else{ | |||||
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes]; | |||||
} | |||||
}else{ | |||||
dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours]; | |||||
} | |||||
} | |||||
if((timeSinceNow/60) >= affectTime){ | |||||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | |||||
if(is24h){ | |||||
[dateFormatter setDateFormat:@"HH:mm"]; | |||||
}else{ | |||||
[dateFormatter setDateFormat:@"h:mm a"]; | |||||
} | |||||
if(addToCurrent && !([dateLabel.text isEqualToString:[dateFormatter stringFromDate:date]])){ | |||||
dateLabel.text = [[dateLabel.text stringByAppendingString:@" • "] stringByAppendingString:[dateFormatter stringFromDate:date]]; | |||||
}else{ | |||||
dateLabel.text =[dateFormatter stringFromDate:date]; | |||||
} | |||||
[dateLabel sizeToFit]; | |||||
[dateFormatter release]; | |||||
} | } | ||||
dateLabel.text = [dateFormatter stringFromDate:date]; | |||||
[dateLabel sizeToFit]; | |||||
[dateFormatter release]; | |||||
} | } | ||||
} | } | ||||
-(void)dateLabelDidChange:(id)arg1{ | -(void)dateLabelDidChange:(id)arg1{ |
Package: com.gilshahar7.exacttime | Package: com.gilshahar7.exacttime | ||||
Name: ExactTime | Name: ExactTime | ||||
Depends: mobilesubstrate | Depends: mobilesubstrate | ||||
Version: 1.0 | |||||
Version: 1.3 | |||||
Architecture: iphoneos-arm | Architecture: iphoneos-arm | ||||
Description: Shows the exact time of a notification. | Description: Shows the exact time of a notification. | ||||
Maintainer: gilshahar7 | Maintainer: gilshahar7 |
#import <Preferences/Preferences.h> | |||||
@interface ExactTimeprefsListController: PSListController { | |||||
} | |||||
@end | |||||
@implementation ExactTimeprefsListController | |||||
- (id)specifiers { | |||||
if(_specifiers == nil) { | |||||
_specifiers = [[self loadSpecifiersFromPlistName:@"ExactTimeprefs" target:self] retain]; | |||||
} | |||||
return _specifiers; | |||||
} | |||||
-(void)apply{ | |||||
[self.view endEditing:YES]; | |||||
} | |||||
@end | |||||
// vim:ft=objc |
ARCHS = armv7 arm64 | |||||
include $(THEOS)/makefiles/common.mk | |||||
BUNDLE_NAME = ExactTimeprefs | |||||
ExactTimeprefs_FILES = ExactTimeprefs.mm | |||||
ExactTimeprefs_INSTALL_PATH = /Library/PreferenceBundles | |||||
ExactTimeprefs_FRAMEWORKS = UIKit | |||||
ExactTimeprefs_PRIVATE_FRAMEWORKS = Preferences | |||||
include $(THEOS_MAKE_PATH)/bundle.mk | |||||
internal-stage:: | |||||
$(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) | |||||
$(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/ExactTimeprefs.plist$(ECHO_END) |
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||||
<plist version="1.0"> | |||||
<dict> | |||||
<key>items</key> | |||||
<array> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSGroupCell</string> | |||||
<key>footerText</key> | |||||
<string>Only show the exact time for notifications older than this value (0~240). Default value for stock iOS is 240 minutes (4 hours)</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSEditTextCell</string> | |||||
<key>defaults</key> | |||||
<string>com.gilshahar7.exacttimeprefs</string> | |||||
<key>key</key> | |||||
<string>affectTime</string> | |||||
<key>default</key> | |||||
<string>10</string> | |||||
<key>isNumeric</key> | |||||
<true/> | |||||
<key>label</key> | |||||
<string>Affect after (in minutes)</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSButtonCell</string> | |||||
<key>defaults</key> <string>com.gilshahar7.exacttimeprefs</string> | |||||
<key>label</key> | |||||
<string>Apply</string> | |||||
<key>action</key> | |||||
<string>apply</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSGroupCell</string> | |||||
<key>footerText</key> | |||||
<string>This will add "Xh ago" where there is an exact time, separated by a ' • ' Note: this will override any language</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSSwitchCell</string> | |||||
<key>default</key> | |||||
<false/> | |||||
<key>defaults</key> | |||||
<string>com.gilshahar7.exacttimeprefs</string> | |||||
<key>key</key> | |||||
<string>addToCurrent</string> | |||||
<key>label</key> | |||||
<string>Add estimated time to exact time</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSGroupCell</string> | |||||
<key>footerText</key> | |||||
<string>This will add minutes to all "Xh ago" Note: this will override any language</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSSwitchCell</string> | |||||
<key>default</key> | |||||
<false/> | |||||
<key>defaults</key> | |||||
<string>com.gilshahar7.exacttimeprefs</string> | |||||
<key>key</key> | |||||
<string>addMinutes</string> | |||||
<key>label</key> | |||||
<string>Change "2h ago" to "2h 17m ago"</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSGroupCell</string> | |||||
<key>footerText</key> | |||||
<string>Made by: gilshahar7.</string> | |||||
</dict> | |||||
</array> | |||||
<key>title</key> | |||||
<string>ExactTime</string> | |||||
</dict> | |||||
</plist> |
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||||
<plist version="1.0"> | |||||
<dict> | |||||
<key>CFBundleDevelopmentRegion</key> | |||||
<string>English</string> | |||||
<key>CFBundleExecutable</key> | |||||
<string>ExactTimeprefs</string> | |||||
<key>CFBundleIdentifier</key> | |||||
<string>com.gilshahar7.exacttimeprefs</string> | |||||
<key>CFBundleInfoDictionaryVersion</key> | |||||
<string>6.0</string> | |||||
<key>CFBundlePackageType</key> | |||||
<string>BNDL</string> | |||||
<key>CFBundleShortVersionString</key> | |||||
<string>1.0.0</string> | |||||
<key>CFBundleSignature</key> | |||||
<string>????</string> | |||||
<key>CFBundleVersion</key> | |||||
<string>1.0</string> | |||||
<key>DTPlatformName</key> | |||||
<string>iphoneos</string> | |||||
<key>MinimumOSVersion</key> | |||||
<string>3.0</string> | |||||
<key>NSPrincipalClass</key> | |||||
<string>ExactTimeprefsListController</string> | |||||
</dict> | |||||
</plist> |
{ | |||||
entry = { | |||||
bundle = ExactTimeprefs; | |||||
cell = PSLinkCell; | |||||
detail = ExactTimeprefsListController; | |||||
icon = ExactTime.png; | |||||
isController = 1; | |||||
label = ExactTime; | |||||
}; | |||||
} |
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||||
<plist version="1.0"> | |||||
<dict> | |||||
<key>items</key> | |||||
<array> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSGroupCell</string> | |||||
<key>footerText</key> | |||||
<string>Only show the exact time for notifications older than this value (0~240). Default value for stock iOS is 240 minutes (4 hours)</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSEditTextCell</string> | |||||
<key>defaults</key> | |||||
<string>com.gilshahar7.exacttimeprefs</string> | |||||
<key>key</key> | |||||
<string>affectTime</string> | |||||
<key>default</key> | |||||
<string>10</string> | |||||
<key>isNumeric</key> | |||||
<true/> | |||||
<key>label</key> | |||||
<string>Affect after (in minutes)</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSButtonCell</string> | |||||
<key>defaults</key> <string>com.gilshahar7.exacttimeprefs</string> | |||||
<key>label</key> | |||||
<string>Apply</string> | |||||
<key>action</key> | |||||
<string>apply</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSGroupCell</string> | |||||
<key>footerText</key> | |||||
<string>This will add "Xh ago" where there is an exact time, separated by a ' • ' Note: this will override any language</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSSwitchCell</string> | |||||
<key>default</key> | |||||
<false/> | |||||
<key>defaults</key> | |||||
<string>com.gilshahar7.exacttimeprefs</string> | |||||
<key>key</key> | |||||
<string>addToCurrent</string> | |||||
<key>label</key> | |||||
<string>Add estimated time to exact time</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSGroupCell</string> | |||||
<key>footerText</key> | |||||
<string>This will add minutes to all "Xh ago" Note: this will override any language</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSSwitchCell</string> | |||||
<key>default</key> | |||||
<false/> | |||||
<key>defaults</key> | |||||
<string>com.gilshahar7.exacttimeprefs</string> | |||||
<key>key</key> | |||||
<string>addMinutes</string> | |||||
<key>label</key> | |||||
<string>Change "2h ago" to "2h 17m ago"</string> | |||||
</dict> | |||||
<dict> | |||||
<key>cell</key> | |||||
<string>PSGroupCell</string> | |||||
<key>footerText</key> | |||||
<string>Made by: gilshahar7.</string> | |||||
</dict> | |||||
</array> | |||||
<key>title</key> | |||||
<string>ExactTime</string> | |||||
</dict> | |||||
</plist> |
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||||
<plist version="1.0"> | |||||
<dict> | |||||
<key>CFBundleDevelopmentRegion</key> | |||||
<string>English</string> | |||||
<key>CFBundleExecutable</key> | |||||
<string>ExactTimeprefs</string> | |||||
<key>CFBundleIdentifier</key> | |||||
<string>com.gilshahar7.exacttimeprefs</string> | |||||
<key>CFBundleInfoDictionaryVersion</key> | |||||
<string>6.0</string> | |||||
<key>CFBundlePackageType</key> | |||||
<string>BNDL</string> | |||||
<key>CFBundleShortVersionString</key> | |||||
<string>1.0.0</string> | |||||
<key>CFBundleSignature</key> | |||||
<string>????</string> | |||||
<key>CFBundleVersion</key> | |||||
<string>1.0</string> | |||||
<key>DTPlatformName</key> | |||||
<string>iphoneos</string> | |||||
<key>MinimumOSVersion</key> | |||||
<string>3.0</string> | |||||
<key>NSPrincipalClass</key> | |||||
<string>ExactTimeprefsListController</string> | |||||
</dict> | |||||
</plist> |