5 Commits

Author SHA1 Message Date
5529eb81a1 Merge branch 'master' of https://github.com/gilshahar7/ExactTime 2020-06-10 22:36:09 +03:00
a716f1cb28 Added 2.0 deb 2020-06-10 21:03:16 +03:00
b522378b1b Update README.md 2020-06-10 21:01:53 +03:00
235149df4f Version 2.0 - Combined all of the ExactTime tweaks. 2020-06-10 21:00:05 +03:00
faa7952e13 Merge pull request #4 from gilshahar7/beta-future-time
Added detection for future dates
2019-12-07 19:35:36 +02:00
31 changed files with 737 additions and 426 deletions

319
ExactTime.xm Normal file
View File

@ -0,0 +1,319 @@
//IOS 10
@interface NCNotificationDateLabel
@property (assign,nonatomic) NSString *text;
-(void)sizeToFit;
@end
//IOS 10
@interface NCLookHeaderContentView
-(void)_updateDateLabelFontForShortLook;
@end
//IOS 11 & 12 And Above
@interface BSUIRelativeDateLabel
@property (assign,nonatomic) NSString *text;
-(void)sizeToFit;
@end
//IOS 11
@interface MTPlatterHeaderContentView
-(void)_updateTextAttributesForDateLabel;
@end
//IOS 12 And Above
@interface PLPlatterHeaderContentView
-(void)_updateTextAttributesForDateLabel;
@end
static bool is24h;
static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist";
%group iOS10
%hook NCLookHeaderContentView
-(void)_updateDateLabelFontForShortLook{
%orig;
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
bool enabled = [[prefs objectForKey:@"notifications"] boolValue];
if(enabled){
NSDate *date = MSHookIvar<NSDate *>(self, "_date");
NSInteger format = MSHookIvar<NSInteger >(self, "_dateFormatStyle");
CGFloat affectTime = [[prefs objectForKey:@"affectTime"] floatValue];
if((date != nil) && (format == 1)){
NCNotificationDateLabel *dateLabel = MSHookIvar<NCNotificationDateLabel *>(self, "_dateLabel");
int timeSinceNow = (int)[date timeIntervalSinceNow];
bool isFuture = false;
if (timeSinceNow > 0){
isFuture = true;
}else{
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{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(minutes == 0){
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours];
}
} else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih %im", hours, minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih %im ago", hours, minutes];
}
}
}
}else if(addToCurrent){
if(hours == 0){
if(minutes == 0){
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}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 _updateDateLabelFontForShortLook];
}
%end
%end
%group iOS11
%hook MTPlatterHeaderContentView
-(void)_updateTextAttributesForDateLabel{
%orig;
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
bool enabled = [[prefs objectForKey:@"notifications"] boolValue];
if(enabled){
NSDate *date = MSHookIvar<NSDate *>(self, "_date");
NSInteger format = MSHookIvar<NSInteger >(self, "_dateFormatStyle");
CGFloat affectTime = [[prefs objectForKey:@"affectTime"] floatValue];
if((date != nil) && (format == 1)){
BSUIRelativeDateLabel *dateLabel = MSHookIvar<BSUIRelativeDateLabel *>(self, "_dateLabel");
int timeSinceNow = (int)[date timeIntervalSinceNow];
bool isFuture = false;
if (timeSinceNow > 0){
isFuture = true;
}else{
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{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(minutes == 0){
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours];
}
} else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih %im", hours, minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih %im ago", hours, minutes];
}
}
}
}else if(addToCurrent){
if(hours == 0){
if(minutes == 0){
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}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
%group iOS12AndAbove
%hook PLPlatterHeaderContentView
-(void)_updateTextAttributesForDateLabel{
%orig;
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
bool enabled = [[prefs objectForKey:@"notifications"] boolValue];
if(enabled){
NSDate *date = MSHookIvar<NSDate *>(self, "_date");
NSInteger format = MSHookIvar<NSInteger >(self, "_dateFormatStyle");
CGFloat affectTime = [[prefs objectForKey:@"affectTime"] floatValue];
if((date != nil) && (format == 1)){
BSUIRelativeDateLabel *dateLabel = MSHookIvar<BSUIRelativeDateLabel *>(self, "_dateLabel");
int timeSinceNow = (int)[date timeIntervalSinceNow];
bool isFuture = false;
if (timeSinceNow > 0){
isFuture = true;
}else{
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{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(minutes == 0){
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours];
}
} else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih %im", hours, minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih %im ago", hours, minutes];
}
}
}
}else if(addToCurrent){
if(hours == 0){
if(minutes == 0){
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}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]];
[formatter setDateStyle:NSDateFormatterNoStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
NSString *dateString = [formatter stringFromDate:[NSDate date]];
NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];
is24h = (amRange.location == NSNotFound && pmRange.location == NSNotFound);
[formatter release];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 11.0) {
%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) {
%init(iOS12AndAbove);
}
}

1
ExactTimeMail.plist Normal file
View File

@ -0,0 +1 @@
{ Filter = { Bundles = ( "com.apple.mobilemail" ); }; }

49
ExactTimeMail.x Normal file
View File

@ -0,0 +1,49 @@
@interface UIDateLabel : UILabel
@property (nonatomic, strong) NSDate *date;
@end
@interface MessageListCellView : UIView
@property (nonatomic, strong) UIDateLabel *dateLabel;
@end
static bool is24h;
static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist";
static bool enabled;
%hook MessageListCellView
-(void)layoutSubviews{
%orig;
if(enabled){
if(![self.dateLabel.text containsString:@":"]){
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
if(is24h){
[dateFormatter setDateFormat:@" • HH:mm"];
}else{
[dateFormatter setDateFormat:@" • h:mm a"];
}
self.dateLabel.textAlignment = 1;
self.dateLabel.numberOfLines = 1;
self.dateLabel.text = [self.dateLabel.text stringByAppendingString:[dateFormatter stringFromDate:self.dateLabel.date]];
[self.dateLabel sizeToFit];
//calling %orig again is not the best thing to do but the label was not positioned correctly after sizing it to fit the new string. If you feel like helping me with this, send a pull request!
%orig;
}
}
}
%end
%ctor{
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
enabled = [[prefs objectForKey:@"mail"] boolValue];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setDateStyle:NSDateFormatterNoStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
NSString *dateString = [formatter stringFromDate:[NSDate date]];
NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];
is24h = (amRange.location == NSNotFound && pmRange.location == NSNotFound);
}

1
ExactTimeMessages.plist Normal file
View File

@ -0,0 +1 @@
{ Filter = { Bundles = ( "com.apple.MobileSMS" ); }; }

41
ExactTimeMessages.xm Normal file
View File

@ -0,0 +1,41 @@
@interface UIDateLabel : UILabel
@property (nonatomic, strong) NSDate *date;
@end
static bool is24h;
static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist";
static bool enabled;
%hook CKConversationListCell
-(void)layoutSubviews{
%orig;
if(enabled){
if(MSHookIvar<UIDateLabel *>(self, "_dateLabel")){
UIDateLabel *dateLabel = MSHookIvar<UIDateLabel *>(self, "_dateLabel");
if(![dateLabel.text containsString:@":"]){
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
if(is24h){
[dateFormatter setDateFormat:@" • HH:mm"];
}else{
[dateFormatter setDateFormat:@" • h:mm a"];
}
dateLabel.text = [dateLabel.text stringByAppendingString:[dateFormatter stringFromDate:dateLabel.date]];
}
}
}
}
%end
%ctor{
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
enabled = [[prefs objectForKey:@"messages"] boolValue];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setDateStyle:NSDateFormatterNoStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
NSString *dateString = [formatter stringFromDate:[NSDate date]];
NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];
is24h = (amRange.location == NSNotFound && pmRange.location == NSNotFound);
}

1
ExactTimePhone.plist Normal file
View File

@ -0,0 +1 @@
{ Filter = { Bundles = ( "com.apple.mobilephone" ); }; }

46
ExactTimePhone.x Normal file
View File

@ -0,0 +1,46 @@
@interface UIDateLabel : UILabel
@property (nonatomic, strong) NSDate *date;
@end
@interface MPRecentsTableViewCell
@property (nonatomic, strong) UIDateLabel *callerDateLabel;
@end
static bool is24h;
static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist";
static bool enabled;
%hook MPRecentsTableViewCell
-(void)layoutSubviews{
%orig;
if(enabled){
if(![self.callerDateLabel.text containsString:@":"]){
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
if(is24h){
[dateFormatter setDateFormat:@"\nHH:mm"];
}else{
[dateFormatter setDateFormat:@"\nh:mm a"];
}
self.callerDateLabel.textAlignment = 2;
self.callerDateLabel.numberOfLines = 2;
self.callerDateLabel.text = [self.callerDateLabel.text stringByAppendingString:[dateFormatter stringFromDate:self.callerDateLabel.date]];
}
}
}
%end
%ctor{
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
enabled = [[prefs objectForKey:@"phone"] boolValue];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setDateStyle:NSDateFormatterNoStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
NSString *dateString = [formatter stringFromDate:[NSDate date]];
NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];
is24h = (amRange.location == NSNotFound && pmRange.location == NSNotFound);
}

View File

@ -2,8 +2,17 @@ ARCHS = armv7 arm64 arm64e
export TARGET = iphone:clang:11.2:7.0
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = ExactTime
ExactTime_FILES = Tweak.xm
DEBUG=0
TWEAK_NAME = ExactTime ExactTimeMail ExactTimePhone ExactTimeMessages
ExactTime_FILES = ExactTime.xm
ExactTimeMail_FILES = ExactTimeMail.x
ExactTimePhone_FILES = ExactTimePhone.x
ExactTimeMessages_FILES = ExactTimeMessages.xm
include $(THEOS_MAKE_PATH)/tweak.mk

View File

@ -1,7 +1,7 @@
# ExactTime
Jailbreak tweak: show the exact time of a notification instead of "1h ago".
Jailbreak tweak: Shows the exact time of notifications, messages, calls and emails.
Requested by /u/XDSS2002 on Reddit.
Originaly requested by /u/XDSS2002 on Reddit.
https://www.reddit.com/r/jailbreak/comments/66xzjt/question_request_tweak_that_shows_exact_time_of/
Available on the Packix repo : https://repo.packix.com/package/com.gilshahar7.exacttime/

310
Tweak.xm
View File

@ -1,310 +0,0 @@
//IOS 10
@interface NCNotificationDateLabel
@property (assign,nonatomic) NSString *text;
-(void)sizeToFit;
@end
//IOS 10
@interface NCLookHeaderContentView
-(void)_updateDateLabelFontForShortLook;
@end
//IOS 11 & 12 And Above
@interface BSUIRelativeDateLabel
@property (assign,nonatomic) NSString *text;
-(void)sizeToFit;
@end
//IOS 11
@interface MTPlatterHeaderContentView
-(void)_updateTextAttributesForDateLabel;
@end
//IOS 12 And Above
@interface PLPlatterHeaderContentView
-(void)_updateTextAttributesForDateLabel;
@end
static bool is24h;
static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist";
%group iOS10
%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");
int timeSinceNow = (int)[date timeIntervalSinceNow];
bool isFuture = false;
if (timeSinceNow > 0){
isFuture = true;
}else{
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{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(minutes == 0){
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours];
}
} else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih %im", hours, minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih %im ago", hours, minutes];
}
}
}
}else if(addToCurrent){
if(hours == 0){
if(minutes == 0){
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}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 _updateDateLabelFontForShortLook];
}
%end
%end
%group iOS11
%hook MTPlatterHeaderContentView
-(void)_updateTextAttributesForDateLabel{
%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)){
BSUIRelativeDateLabel *dateLabel = MSHookIvar<BSUIRelativeDateLabel *>(self, "_dateLabel");
int timeSinceNow = (int)[date timeIntervalSinceNow];
bool isFuture = false;
if (timeSinceNow > 0){
isFuture = true;
}else{
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{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(minutes == 0){
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours];
}
} else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih %im", hours, minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih %im ago", hours, minutes];
}
}
}
}else if(addToCurrent){
if(hours == 0){
if(minutes == 0){
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}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
%group iOS12AndAbove
%hook PLPlatterHeaderContentView
-(void)_updateTextAttributesForDateLabel{
%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)){
BSUIRelativeDateLabel *dateLabel = MSHookIvar<BSUIRelativeDateLabel *>(self, "_dateLabel");
int timeSinceNow = (int)[date timeIntervalSinceNow];
bool isFuture = false;
if (timeSinceNow > 0){
isFuture = true;
}else{
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{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(minutes == 0){
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours];
}
} else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih %im", hours, minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%ih %im ago", hours, minutes];
}
}
}
}else if(addToCurrent){
if(hours == 0){
if(minutes == 0){
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %im", minutes];
}else{
dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
}
}
}else{
if(isFuture){
dateLabel.text = [NSString stringWithFormat:@"in %ih", hours];
}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]];
[formatter setDateStyle:NSDateFormatterNoStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
NSString *dateString = [formatter stringFromDate:[NSDate date]];
NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];
is24h = (amRange.location == NSNotFound && pmRange.location == NSNotFound);
[formatter release];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 11.0) {
%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) {
%init(iOS12AndAbove);
}
}

View File

@ -1,9 +1,10 @@
Package: com.gilshahar7.exacttime
Name: ExactTime
Depends: mobilesubstrate
Version: 1.8
Conflicts: com.gilshahar7.exacttimemail, com.gilshahar7.exacttimephone, com.gilshahar7.exacttimemessages
Version: 2.0
Architecture: iphoneos-arm
Description: Shows the exact time of a notification.
Description: Shows the exact time of notifications, messages, calls and emails.
Maintainer: gilshahar7
Author: gilshahar7
Section: Tweaks

View File

@ -1,20 +1,148 @@
#import <Preferences/PSListController.h>
#import <Preferences/PSSpecifier.h>
@interface ExactTimeprefsListController: PSListController {
}
@interface PSListController (iOS12Plus)
-(BOOL)containsSpecifier:(id)arg1;
@end
@interface ExactTimeprefsListController : PSListController
@property (nonatomic, retain) NSMutableDictionary *savedSpecifiers;
@end
@implementation ExactTimeprefsListController
- (id)readPreferenceValue:(PSSpecifier*)specifier {
NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
NSMutableDictionary *settings = [NSMutableDictionary dictionary];
[settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
return (settings[specifier.properties[@"key"]]) ?: specifier.properties[@"default"];
}
- (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier {
NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
NSMutableDictionary *settings = [NSMutableDictionary dictionary];
[settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
[settings setObject:value forKey:specifier.properties[@"key"]];
[settings writeToFile:path atomically:YES];
CFStringRef notificationName = (CFStringRef)specifier.properties[@"PostNotification"];
if (notificationName) {
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), notificationName, NULL, NULL, YES);
}
//Here we check if the switch is on based of the key of the PSSwitchCell, then hide the specifier
//We then hide the cell using the id of it. If its already hidden we reinsert the cell below a certain specifier based on its ID
NSString *key = [specifier propertyForKey:@"key"];
if([key isEqualToString:@"notifications"]) {
if([value boolValue]) {
[self insertContiguousSpecifiers:@[self.savedSpecifiers[@"96"]] afterSpecifierID:@"95" animated:YES];
[self insertContiguousSpecifiers:@[self.savedSpecifiers[@"97"]] afterSpecifierID:@"96" animated:YES];
[self insertContiguousSpecifiers:@[self.savedSpecifiers[@"98"]] afterSpecifierID:@"97" animated:YES];
[self insertContiguousSpecifiers:@[self.savedSpecifiers[@"99"]] afterSpecifierID:@"98" animated:YES];
[self insertContiguousSpecifiers:@[self.savedSpecifiers[@"100"]] afterSpecifierID:@"99" animated:YES];
[self insertContiguousSpecifiers:@[self.savedSpecifiers[@"101"]] afterSpecifierID:@"100" animated:YES];
[self insertContiguousSpecifiers:@[self.savedSpecifiers[@"102"]] afterSpecifierID:@"101" animated:YES];
} else if([self containsSpecifier:self.savedSpecifiers[@"96"]]) {
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"96"]] animated:YES];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"97"]] animated:YES];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"98"]] animated:YES];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"99"]] animated:YES];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"100"]] animated:YES];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"101"]] animated:YES];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"102"]] animated:YES];
}
}
}
- (id)specifiers {
if(_specifiers == nil) {
_specifiers = [[self loadSpecifiersFromPlistName:@"ExactTimeprefs" target:self] retain];
}
//Code to save certain specifiers
//Add the id of the specifier to the chosenIDs array.
//Only add the IDs of the specifiers you want to hide
NSArray *chosenIDs = @[@"96", @"97", @"98", @"99", @"100", @"101", @"102"];
self.savedSpecifiers = (!self.savedSpecifiers) ? [[NSMutableDictionary alloc] init] : self.savedSpecifiers;
for(PSSpecifier *specifier in _specifiers) {
if([chosenIDs containsObject:[specifier propertyForKey:@"id"]]) {
[self.savedSpecifiers setObject:specifier forKey:[specifier propertyForKey:@"id"]];
}
}
return _specifiers;
}
-(void)apply{
[self.view endEditing:YES];
-(void)viewDidLoad {
[super viewDidLoad];
//From my testing, at this point we can't get the value of a specifier yet as they haven't loaded
//Instead you can just read your switch value from your preferences file
NSDictionary *preferences = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist"];
if(![preferences[@"notifications"] boolValue] == true) {
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"96"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"97"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"98"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"99"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"100"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"101"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"102"]] animated:NO];
}
}
-(void)reloadSpecifiers {
[super reloadSpecifiers];
//This will look the exact same as step 5, where we only check if specifiers need to be removed
NSDictionary *preferences = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist"];
if([preferences[@"notifications"] boolValue] == false) {
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"96"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"97"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"98"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"99"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"100"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"101"]] animated:NO];
[self removeContiguousSpecifiers:@[self.savedSpecifiers[@"102"]] animated:NO];
}
}
- (void)loadView {
[super loadView];
((UITableView *)[self table]).keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
}
-(void)_returnKeyPressed:(id)arg1 { [self.view endEditing:YES]; }
-(void)apply{
[self.view endEditing:YES];
}
- (void)sourceLink
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://github.com/gilshahar7/ExactTime"]];
}
- (void)donationLink
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.paypal.me/gilshahar7"]];
}
- (void)openTwitterWithUsername:(NSString*)username
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://twitter.com/%@", username]]];
}
- (void)openTwitter
{
[self openTwitterWithUsername:@"gilshahar7"];
}
- (void)reddit {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.reddit.com/user/gilshahar7/"]];
}
- (void)sendEmail {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:gilshahardex99@gmail.com?subject=ExactTime"]];
}
@end
// vim:ft=objc

View File

@ -2,6 +2,8 @@ ARCHS = armv7 arm64 arm64e
export TARGET = iphone:clang:11.2:7.0
include $(THEOS)/makefiles/common.mk
DEBUG=0
BUNDLE_NAME = ExactTimeprefs
ExactTimeprefs_FILES = ExactTimeprefs.mm
ExactTimeprefs_INSTALL_PATH = /Library/PreferenceBundles

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -7,8 +7,70 @@
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>Choose extentions</string>
<key>footerText</key>
<string></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>notifications</string>
<key>label</key>
<string>Notifications</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>messages</string>
<key>label</key>
<string>Messages</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>phone</string>
<key>label</key>
<string>Phone</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>mail</string>
<key>label</key>
<string>Mail</string>
<key>id</key>
<string>95</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>Notifications settings</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>
<key>id</key>
<string>96</string>
</dict>
<dict>
<key>cell</key>
@ -23,21 +85,28 @@
<true/>
<key>label</key>
<string>Affect after (in minutes)</string>
<key>id</key>
<string>97</string>
</dict>
<dict>
<key>cell</key>
<string>PSButtonCell</string>
<key>defaults</key> <string>com.gilshahar7.exacttimeprefs</string>
<key>defaults</key>
<string>com.gilshahar7.exacttimeprefs</string>
<key>label</key>
<string>Apply</string>
<key>action</key>
<string>apply</string>
<key>id</key>
<string>98</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>
<key>id</key>
<string>99</string>
</dict>
<dict>
<key>cell</key>
@ -50,12 +119,16 @@
<string>addToCurrent</string>
<key>label</key>
<string>Add estimated time to exact time</string>
<key>id</key>
<string>100</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>
<key>id</key>
<string>101</string>
</dict>
<dict>
<key>cell</key>
@ -68,12 +141,66 @@
<string>addMinutes</string>
<key>label</key>
<string>Change "2h ago" to "2h 17m ago"</string>
<key>id</key>
<string>102</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>About</string>
<key>footerText</key>
<string>Made by: gilshahar7.</string>
<string>Made by gilshahar7</string>
</dict>
<dict>
<key>action</key>
<string>reddit</string>
<key>cell</key>
<string>PSButtonCell</string>
<key>icon</key>
<string>Reddit</string>
<key>label</key>
<string>Reddit (u/gilshahar7)</string>
</dict>
<dict>
<key>action</key>
<string>sendEmail</string>
<key>cell</key>
<string>PSButtonCell</string>
<key>icon</key>
<string>Email</string>
<key>label</key>
<string>Email</string>
</dict>
<dict>
<key>action</key>
<string>openTwitter</string>
<key>cell</key>
<string>PSButtonCell</string>
<key>icon</key>
<string>Twitter</string>
<key>label</key>
<string>Twitter (@gilshahar7)</string>
</dict>
<dict>
<key>action</key>
<string>sourceLink</string>
<key>cell</key>
<string>PSButtonCell</string>
<key>icon</key>
<string>GitHub</string>
<key>label</key>
<string>Source Code</string>
</dict>
<dict>
<key>action</key>
<string>donationLink</string>
<key>cell</key>
<string>PSButtonCell</string>
<key>icon</key>
<string>Donate</string>
<key>label</key>
<string>Donate</string>
</dict>
</array>
<key>title</key>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -1,82 +0,0 @@
<?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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,5 +0,0 @@
#import <Preferences/PSListController.h>
@interface RootListController : PSListController
@end

View File

@ -1,17 +0,0 @@
#include "RootListController.h"
@implementation RootListController
- (NSArray *)specifiers {
if (!_specifiers) {
_specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
}
return _specifiers;
}
-(void)apply{
[self.view endEditing:YES];
}
@end

BIN
icon.psd Normal file

Binary file not shown.

Binary file not shown.