Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

47 linhas
1.5KB

  1. @interface UIDateLabel : UILabel
  2. @property (nonatomic, strong) NSDate *date;
  3. @end
  4. @interface MPRecentsTableViewCell
  5. @property (nonatomic, strong) UIDateLabel *callerDateLabel;
  6. @end
  7. static bool is24h;
  8. static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist";
  9. static bool enabled;
  10. %hook MPRecentsTableViewCell
  11. -(void)layoutSubviews{
  12. %orig;
  13. if(enabled){
  14. if(![self.callerDateLabel.text containsString:@":"]){
  15. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  16. if(is24h){
  17. [dateFormatter setDateFormat:@"\nHH:mm"];
  18. }else{
  19. [dateFormatter setDateFormat:@"\nh:mm a"];
  20. }
  21. self.callerDateLabel.textAlignment = 2;
  22. self.callerDateLabel.numberOfLines = 2;
  23. self.callerDateLabel.text = [self.callerDateLabel.text stringByAppendingString:[dateFormatter stringFromDate:self.callerDateLabel.date]];
  24. }
  25. }
  26. }
  27. %end
  28. %ctor{
  29. NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
  30. enabled = [[prefs objectForKey:@"phone"] boolValue];
  31. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  32. [formatter setLocale:[NSLocale currentLocale]];
  33. [formatter setDateStyle:NSDateFormatterNoStyle];
  34. [formatter setTimeStyle:NSDateFormatterShortStyle];
  35. NSString *dateString = [formatter stringFromDate:[NSDate date]];
  36. NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
  37. NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];
  38. is24h = (amRange.location == NSNotFound && pmRange.location == NSNotFound);
  39. }