forked from gilshahar7/ExactTime
Version 1.3
*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.
This commit is contained in:
2
Makefile
2
Makefile
@ -8,3 +8,5 @@ include $(THEOS_MAKE_PATH)/tweak.mk
|
||||
|
||||
after-install::
|
||||
install.exec "killall -9 SpringBoard"
|
||||
SUBPROJECTS += exacttimeprefs
|
||||
include $(THEOS_MAKE_PATH)/aggregate.mk
|
||||
|
56
Tweak.xm
56
Tweak.xm
@ -8,24 +8,62 @@
|
||||
@end
|
||||
|
||||
static bool is24h;
|
||||
static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist";
|
||||
|
||||
|
||||
%hook NCLookHeaderContentView
|
||||
-(void)_updateDateLabelFontForShortLook{
|
||||
%orig;
|
||||
NSDate *date = MSHookIvar<NSDate *>(self, "_date");
|
||||
NSInteger format = MSHookIvar<NSInteger >(self, "_dateFormatStyle");
|
||||
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
|
||||
CGFloat affectTime = [[prefs objectForKey:@"affectTime"] floatValue];
|
||||
if((date != nil) && (format == 1)){
|
||||
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{
|
||||
|
2
control
2
control
@ -1,7 +1,7 @@
|
||||
Package: com.gilshahar7.exacttime
|
||||
Name: ExactTime
|
||||
Depends: mobilesubstrate
|
||||
Version: 1.0
|
||||
Version: 1.3
|
||||
Architecture: iphoneos-arm
|
||||
Description: Shows the exact time of a notification.
|
||||
Maintainer: gilshahar7
|
||||
|
20
exacttimeprefs/ExactTimeprefs.mm
Normal file
20
exacttimeprefs/ExactTimeprefs.mm
Normal file
@ -0,0 +1,20 @@
|
||||
#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
|
14
exacttimeprefs/Makefile
Normal file
14
exacttimeprefs/Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
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)
|
BIN
exacttimeprefs/Resources/ExactTime@2x.png
Normal file
BIN
exacttimeprefs/Resources/ExactTime@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
82
exacttimeprefs/Resources/ExactTimeprefs.plist
Normal file
82
exacttimeprefs/Resources/ExactTimeprefs.plist
Normal file
@ -0,0 +1,82 @@
|
||||
<?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>
|
28
exacttimeprefs/Resources/Info.plist
Normal file
28
exacttimeprefs/Resources/Info.plist
Normal file
@ -0,0 +1,28 @@
|
||||
<?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>
|
10
exacttimeprefs/entry.plist
Normal file
10
exacttimeprefs/entry.plist
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
entry = {
|
||||
bundle = ExactTimeprefs;
|
||||
cell = PSLinkCell;
|
||||
detail = ExactTimeprefsListController;
|
||||
icon = ExactTime.png;
|
||||
isController = 1;
|
||||
label = ExactTime;
|
||||
};
|
||||
}
|
BIN
exacttimeprefs/obj/ExactTimeprefs.bundle/ExactTimeprefs
Normal file
BIN
exacttimeprefs/obj/ExactTimeprefs.bundle/ExactTimeprefs
Normal file
Binary file not shown.
@ -0,0 +1,82 @@
|
||||
<?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>
|
28
exacttimeprefs/obj/ExactTimeprefs.bundle/Info.plist
Normal file
28
exacttimeprefs/obj/ExactTimeprefs.bundle/Info.plist
Normal file
@ -0,0 +1,28 @@
|
||||
<?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>
|
BIN
exacttimeprefs/obj/ExactTimeprefs.mm.4bb0a109.o
Normal file
BIN
exacttimeprefs/obj/ExactTimeprefs.mm.4bb0a109.o
Normal file
Binary file not shown.
Reference in New Issue
Block a user