Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 7 roky
před 7 roky
před 7 roky
před 7 roky
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. @interface NCNotificationDateLabel
  2. @property (assign,nonatomic) NSString *text;
  3. -(void)sizeToFit;
  4. @end
  5. @interface NCLookHeaderContentView
  6. -(void)_updateDateLabelFontForShortLook;
  7. @end
  8. static bool is24h;
  9. static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.exacttimeprefs.plist";
  10. %hook NCLookHeaderContentView
  11. -(void)_updateDateLabelFontForShortLook{
  12. %orig;
  13. NSDate *date = MSHookIvar<NSDate *>(self, "_date");
  14. NSInteger format = MSHookIvar<NSInteger >(self, "_dateFormatStyle");
  15. NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
  16. CGFloat affectTime = [[prefs objectForKey:@"affectTime"] floatValue];
  17. if((date != nil) && (format == 1)){
  18. NCNotificationDateLabel *dateLabel = MSHookIvar<NCNotificationDateLabel *>(self, "_dateLabel");
  19. int timeSinceNow = (int)[date timeIntervalSinceNow];
  20. timeSinceNow = timeSinceNow*-1;
  21. bool addMinutes = [[prefs objectForKey:@"addMinutes"] boolValue];
  22. bool addToCurrent = [[prefs objectForKey:@"addToCurrent"] boolValue];
  23. int hours = timeSinceNow / 3600;
  24. int minutes = (timeSinceNow % 3600) / 60;
  25. if(addMinutes){
  26. if(hours == 0){
  27. if(minutes == 0){
  28. }else{
  29. dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
  30. }
  31. }else{
  32. if(minutes == 0){
  33. dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours];
  34. } else{
  35. dateLabel.text = [NSString stringWithFormat:@"%ih %im ago", hours, minutes];
  36. }
  37. }
  38. }else if(addToCurrent){
  39. if(hours == 0){
  40. if(minutes == 0){
  41. }else{
  42. dateLabel.text = [NSString stringWithFormat:@"%im ago", minutes];
  43. }
  44. }else{
  45. dateLabel.text = [NSString stringWithFormat:@"%ih ago", hours];
  46. }
  47. }
  48. if((timeSinceNow/60) >= affectTime){
  49. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  50. if(is24h){
  51. [dateFormatter setDateFormat:@"HH:mm"];
  52. }else{
  53. [dateFormatter setDateFormat:@"h:mm a"];
  54. }
  55. if(addToCurrent && !([dateLabel.text isEqualToString:[dateFormatter stringFromDate:date]])){
  56. dateLabel.text = [[dateLabel.text stringByAppendingString:@" • "] stringByAppendingString:[dateFormatter stringFromDate:date]];
  57. }else{
  58. dateLabel.text =[dateFormatter stringFromDate:date];
  59. }
  60. [dateLabel sizeToFit];
  61. [dateFormatter release];
  62. }
  63. }
  64. }
  65. -(void)dateLabelDidChange:(id)arg1{
  66. %orig(arg1);
  67. [self _updateDateLabelFontForShortLook];
  68. }
  69. %end
  70. %ctor{
  71. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  72. [formatter setLocale:[NSLocale currentLocale]];
  73. [formatter setDateStyle:NSDateFormatterNoStyle];
  74. [formatter setTimeStyle:NSDateFormatterShortStyle];
  75. NSString *dateString = [formatter stringFromDate:[NSDate date]];
  76. NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
  77. NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];
  78. is24h = (amRange.location == NSNotFound && pmRange.location == NSNotFound);
  79. [formatter release];
  80. }