diff --git a/ExactTimeMessages.plist b/ExactTimeMessages.plist new file mode 100644 index 0000000..b971366 --- /dev/null +++ b/ExactTimeMessages.plist @@ -0,0 +1 @@ +{ Filter = { Bundles = ( "com.apple.MobileSMS" ); }; } diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..77ddad8 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +export ARCHS = armv7 arm64 + +include $(THEOS)/makefiles/common.mk + +TWEAK_NAME = ExactTimeMessages +ExactTimeMessages_FILES = Tweak.xm +ExactTimeMessages_CFLAGS = -fobjc-arc + +include $(THEOS_MAKE_PATH)/tweak.mk + +after-install:: + install.exec "killall -9 MobileSMS" diff --git a/Tweak.xm b/Tweak.xm new file mode 100644 index 0000000..4b8423e --- /dev/null +++ b/Tweak.xm @@ -0,0 +1,34 @@ +@interface UIDateLabel : UILabel +@property (nonatomic, strong) NSDate *date; +@end +static bool is24h; + + +%hook CKConversationListCell +-(void)layoutSubviews{ + %orig; + if(MSHookIvar(self, "_dateLabel")){ + UIDateLabel *dateLabel = MSHookIvar(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{ + 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); +} \ No newline at end of file diff --git a/control b/control new file mode 100644 index 0000000..d38aa5a --- /dev/null +++ b/control @@ -0,0 +1,9 @@ +Package: com.gilshahar7.exacttimemessages +Name: ExactTimeMessages +Depends: mobilesubstrate +Version: 1.0 +Architecture: iphoneos-arm +Description: Adds an exact time to the message cells in the stock messages app. +Maintainer: gilshahar7 +Author: gilshahar7 +Section: Tweaks