Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

185 lines
5.2KB

  1. #define kScreenWidth [[UIScreen mainScreen] bounds].size.width
  2. @interface SBTodayTableHeaderView : UIView
  3. -(NSString *)lunarDateHeaderString;
  4. @end
  5. @interface SBAnimationSettings
  6. @end
  7. @interface SBFadeAnimationSettings
  8. @property(retain, nonatomic) SBAnimationSettings *dateInSettings;
  9. @end
  10. @interface SBFLockScreenDateView : UIView
  11. @property (nonatomic, retain) UILabel *duplexCalendarLabel;
  12. @property (nonatomic, assign) NSString *todayHeaderViewText;
  13. @property bool dateHidden;
  14. -(id)_dateFont;
  15. -(id)_dateColor;
  16. -(BOOL)isDateHidden;
  17. -(void)layoutDuplexCalendarLabel;
  18. @end
  19. @interface _UILegibilityView : UIView
  20. @end
  21. @interface _UILegibilityLabel : _UILegibilityView
  22. @end
  23. extern "C" CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void);
  24. static NSString *myObserver=@"duplexcalendarObserver";
  25. static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.duplexcalendarprefs.plist";
  26. static NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
  27. static void savePressed(){
  28. prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
  29. }
  30. static void savePressed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo){
  31. prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
  32. }
  33. static BOOL isiOS9 = NO;
  34. static BOOL isiOS8Refreshed = NO;
  35. static SBTodayTableHeaderView *stattodayHeaderView;
  36. static SBFLockScreenDateView *lockScreenDateView;
  37. static float originx = 0.0;
  38. static float originy = 0.0;
  39. static float sizewidth = 0.0;
  40. static float sizeheight = 0.0;
  41. %hook SBTodayTableHeaderView
  42. -(SBTodayTableHeaderView *)initWithFrame:(CGRect)arg1{
  43. stattodayHeaderView = %orig();
  44. return stattodayHeaderView;
  45. }
  46. -(void)_layoutLunarDateLabel{
  47. %orig;
  48. if(isiOS9) return;
  49. if(!isiOS8Refreshed) {
  50. isiOS8Refreshed = YES;
  51. [lockScreenDateView _updateLabels];
  52. lockScreenDateView = nil;
  53. }
  54. }
  55. %end
  56. %hook SBFLockScreenDateView
  57. %property (nonatomic, retain) UILabel *duplexCalendarLabel;
  58. %property (nonatomic, assign) NSString *todayHeaderViewText;
  59. -(SBFLockScreenDateView *)initWithFrame:(id)arg1{
  60. lockScreenDateView = %orig(arg1);
  61. if(!self.duplexCalendarLabel){
  62. self.duplexCalendarLabel = [[UILabel alloc] initWithFrame:CGRectMake(originx-50, originy + 19, sizewidth+100, sizeheight)];
  63. self.duplexCalendarLabel.font = [[self _dateFont] fontWithSize:16];
  64. [self addSubview:self.duplexCalendarLabel];
  65. self.duplexCalendarLabel.textColor = [self _dateColor];
  66. self.duplexCalendarLabel.textAlignment = 1;
  67. }
  68. return lockScreenDateView;
  69. }
  70. %new
  71. -(void)layoutDuplexCalendarLabel{
  72. NSString *offsetXTextField = [prefs objectForKey:@"offsetXTextField"];
  73. NSString *offsetYTextField = [prefs objectForKey:@"offsetYTextField"];
  74. NSString *FontSizeTextField = [prefs objectForKey:@"FontSizeTextField"];
  75. //if(originx <= 0.0)
  76. //{
  77. UILabel *originalLabel = MSHookIvar<UILabel *>(self, "_dateLabel");
  78. originx = originalLabel.frame.origin.x;
  79. originy = originalLabel.frame.origin.y;
  80. sizewidth = originalLabel.frame.size.width;
  81. sizeheight = originalLabel.frame.size.height;
  82. self.duplexCalendarLabel.textColor = [self _dateColor];
  83. //}
  84. [self.duplexCalendarLabel setFrame:CGRectMake(originx-50+ [offsetXTextField floatValue], originy + 19 + [offsetYTextField floatValue], sizewidth+100, sizeheight)];
  85. UIFont *font = self.duplexCalendarLabel.font;
  86. if([FontSizeTextField floatValue] == 0){
  87. self.duplexCalendarLabel.font = [font fontWithSize:16.0];
  88. }else{
  89. self.duplexCalendarLabel.font = [font fontWithSize:[FontSizeTextField floatValue]];
  90. }
  91. if(isiOS9 && self.duplexCalendarLabel){
  92. if([self isDateHidden]){
  93. self.duplexCalendarLabel.hidden = true;
  94. }else{
  95. self.duplexCalendarLabel.hidden = false;
  96. }
  97. }
  98. }
  99. -(void)_updateLabels{
  100. %orig;
  101. [self layoutDuplexCalendarLabel];
  102. //if(!self.todayHeaderViewText){
  103. self.todayHeaderViewText = [stattodayHeaderView lunarDateHeaderString];
  104. //}
  105. self.duplexCalendarLabel.text = self.todayHeaderViewText;
  106. }
  107. -(void)_layoutDateLabel {
  108. %orig;
  109. [self layoutDuplexCalendarLabel];
  110. _UILegibilityLabel *originalLegibilityLabel = MSHookIvar<_UILegibilityLabel *>(self, "_legibilityDateLabel");
  111. [originalLegibilityLabel setFrame:CGRectMake(originx, originy - 3, sizewidth, sizeheight)];
  112. }
  113. -(void)updateFormat{
  114. %orig;
  115. [self layoutDuplexCalendarLabel];
  116. }
  117. -(void)layoutSubviews {
  118. %orig;
  119. [self layoutDuplexCalendarLabel];
  120. }
  121. -(void)setDateHidden:(bool)arg1{
  122. %orig(arg1);
  123. if(isiOS9 && self.duplexCalendarLabel){
  124. self.duplexCalendarLabel.hidden = arg1;
  125. }
  126. }
  127. -(void)_setDateAlpha:(double)arg1{
  128. %orig(arg1);
  129. if(!isiOS9 && self.duplexCalendarLabel){
  130. UILabel *originalLabel = MSHookIvar<UILabel *>(self, "_dateLabel");
  131. self.duplexCalendarLabel.alpha = originalLabel.alpha;
  132. }
  133. }
  134. %end
  135. %hook SBFadeAnimationSettings
  136. - (void)setDefaultValues {
  137. %orig;
  138. self.dateInSettings = nil;
  139. }
  140. %end
  141. %ctor{
  142. if(@available(iOS 9.0, *)) isiOS9 = YES;
  143. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
  144. (void*)myObserver,
  145. savePressed,
  146. CFSTR("duplexcalendar.savepressed"),
  147. NULL,
  148. CFNotificationSuspensionBehaviorDeliverImmediately);
  149. savePressed();
  150. }