diff --git a/Makefile b/Makefile index 00601e8..9913a62 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ - -ARCHS = armv7 arm64 +ARCHS = armv7 arm64 arm64e +export TARGET = iphone:clang:11.2:7.0 include $(THEOS)/makefiles/common.mk TWEAK_NAME = ExactTime diff --git a/Tweak.xm b/Tweak.xm index 1c83600..39a15c0 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -7,7 +7,7 @@ @interface NCLookHeaderContentView -(void)_updateDateLabelFontForShortLook; @end -//IOS 11 +//IOS 11 & 12 @interface BSUIRelativeDateLabel @property (assign,nonatomic) NSString *text; -(void)sizeToFit; @@ -16,6 +16,11 @@ @interface MTPlatterHeaderContentView -(void)_updateTextAttributesForDateLabel; @end +//IOS 12 +@interface PLPlatterHeaderContentView +-(void)_updateTextAttributesForDateLabel; +@end + static bool is24h; @@ -147,6 +152,69 @@ static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7 %end %end +%group iOS12 + %hook PLPlatterHeaderContentView + -(void)_updateTextAttributesForDateLabel{ + %orig; + NSDate *date = MSHookIvar(self, "_date"); + NSInteger format = MSHookIvar(self, "_dateFormatStyle"); + NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath]; + CGFloat affectTime = [[prefs objectForKey:@"affectTime"] floatValue]; + if((date != nil) && (format == 1)){ + BSUIRelativeDateLabel *dateLabel = MSHookIvar(self, "_dateLabel"); + 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]; + } + } + } + -(void)dateLabelDidChange:(id)arg1{ + %orig(arg1); + [self _updateTextAttributesForDateLabel]; + } + %end +%end + %ctor{ NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setLocale:[NSLocale currentLocale]]; @@ -161,5 +229,7 @@ static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7 %init(iOS10); } else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 12.0) { %init(iOS11); + }else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 12.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 13.0) { + %init(iOS12); } -} +} \ No newline at end of file diff --git a/control b/control index f6fce07..d44db1b 100644 --- a/control +++ b/control @@ -1,7 +1,7 @@ Package: com.gilshahar7.exacttime Name: ExactTime Depends: mobilesubstrate -Version: 1.4 +Version: 1.6 Architecture: iphoneos-arm Description: Shows the exact time of a notification. Maintainer: gilshahar7 diff --git a/exacttimeprefs/ExactTimeprefs.mm b/exacttimeprefs/ExactTimeprefs.mm new file mode 100644 index 0000000..742e87d --- /dev/null +++ b/exacttimeprefs/ExactTimeprefs.mm @@ -0,0 +1,20 @@ +#import + +@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 diff --git a/exacttimeprefs/Makefile b/exacttimeprefs/Makefile index b271a8e..c561de6 100644 --- a/exacttimeprefs/Makefile +++ b/exacttimeprefs/Makefile @@ -1,9 +1,9 @@ -ARCHS = armv7 arm64 - +ARCHS = armv7 arm64 arm64e +export TARGET = iphone:clang:11.2:7.0 include $(THEOS)/makefiles/common.mk BUNDLE_NAME = ExactTimeprefs -ExactTimeprefs_FILES = RootListController.m +ExactTimeprefs_FILES = ExactTimeprefs.mm ExactTimeprefs_INSTALL_PATH = /Library/PreferenceBundles ExactTimeprefs_FRAMEWORKS = UIKit ExactTimeprefs_PRIVATE_FRAMEWORKS = Preferences diff --git a/packages/com.gilshahar7.exacttime_1.6_iphoneos-arm.deb b/packages/com.gilshahar7.exacttime_1.6_iphoneos-arm.deb new file mode 100644 index 0000000..19ab281 Binary files /dev/null and b/packages/com.gilshahar7.exacttime_1.6_iphoneos-arm.deb differ