You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Tweak.xm 4.6KB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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, assign) 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 SBTodayTableHeaderView *stattodayHeaderView;
  34. static float originx = 0.0;
  35. static float originy = 0.0;
  36. static float sizewidth = 0.0;
  37. static float sizeheight = 0.0;
  38. %hook SBTodayTableHeaderView
  39. -(SBTodayTableHeaderView *)initWithFrame:(CGRect)arg1{
  40. stattodayHeaderView = %orig();
  41. return stattodayHeaderView;
  42. }
  43. %end
  44. %hook SBFLockScreenDateView
  45. %property (nonatomic, assign) UILabel *duplexCalendarLabel;
  46. %property (nonatomic, assign) NSString *todayHeaderViewText;
  47. -(SBFLockScreenDateView *)initWithFrame:(id)arg1{
  48. SBFLockScreenDateView *origself = %orig(arg1);
  49. if(!self.duplexCalendarLabel){
  50. self.duplexCalendarLabel = [[UILabel alloc] initWithFrame:CGRectMake(originx-50, originy + 19, sizewidth+100, sizeheight)];
  51. self.duplexCalendarLabel.font = [[self _dateFont] fontWithSize:16];
  52. [self addSubview:self.duplexCalendarLabel];
  53. self.duplexCalendarLabel.textColor = [self _dateColor];
  54. self.duplexCalendarLabel.textAlignment = 1;
  55. }
  56. return origself;
  57. }
  58. %new
  59. -(void)layoutDuplexCalendarLabel{
  60. NSString *offsetXTextField = [prefs objectForKey:@"offsetXTextField"];
  61. NSString *offsetYTextField = [prefs objectForKey:@"offsetYTextField"];
  62. NSString *FontSizeTextField = [prefs objectForKey:@"FontSizeTextField"];
  63. //if(originx <= 0.0)
  64. //{
  65. UILabel *originalLabel = MSHookIvar<UILabel *>(self, "_dateLabel");
  66. originx = originalLabel.frame.origin.x;
  67. originy = originalLabel.frame.origin.y;
  68. sizewidth = originalLabel.frame.size.width;
  69. sizeheight = originalLabel.frame.size.height;
  70. self.duplexCalendarLabel.textColor = [self _dateColor];
  71. //}
  72. [self.duplexCalendarLabel setFrame:CGRectMake(originx-50+ [offsetXTextField floatValue], originy + 19 + [offsetYTextField floatValue], sizewidth+100, sizeheight)];
  73. UIFont *font = self.duplexCalendarLabel.font;
  74. if([FontSizeTextField floatValue] == 0){
  75. self.duplexCalendarLabel.font = [font fontWithSize:16.0];
  76. }else{
  77. self.duplexCalendarLabel.font = [font fontWithSize:[FontSizeTextField floatValue]];
  78. }
  79. if(self.duplexCalendarLabel){
  80. if([self isDateHidden]){
  81. self.duplexCalendarLabel.hidden = true;
  82. }else{
  83. self.duplexCalendarLabel.hidden = false;
  84. }
  85. }
  86. }
  87. -(void)_updateLabels{
  88. %orig;
  89. [self layoutDuplexCalendarLabel];
  90. //if(!self.todayHeaderViewText){
  91. self.todayHeaderViewText = [stattodayHeaderView lunarDateHeaderString];
  92. //}
  93. self.duplexCalendarLabel.text = self.todayHeaderViewText;
  94. }
  95. -(void)_layoutDateLabel {
  96. %orig;
  97. [self layoutDuplexCalendarLabel];
  98. _UILegibilityLabel *originalLegibilityLabel = MSHookIvar<_UILegibilityLabel *>(self, "_legibilityDateLabel");
  99. [originalLegibilityLabel setFrame:CGRectMake(originx, originy - 3, sizewidth, sizeheight)];
  100. }
  101. -(void)updateFormat{
  102. %orig;
  103. [self layoutDuplexCalendarLabel];
  104. }
  105. -(void)layoutSubviews {
  106. %orig;
  107. [self layoutDuplexCalendarLabel];
  108. }
  109. -(void)setDateHidden:(bool)arg1{
  110. %orig(arg1);
  111. if(self.duplexCalendarLabel){
  112. self.duplexCalendarLabel.hidden = arg1;
  113. }
  114. }
  115. %end
  116. %hook SBFadeAnimationSettings
  117. - (void)setDefaultValues {
  118. %orig;
  119. self.dateInSettings = nil;
  120. }
  121. %end
  122. %ctor{
  123. CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
  124. (void*)myObserver,
  125. savePressed,
  126. CFSTR("duplexcalendar.savepressed"),
  127. NULL,
  128. CFNotificationSuspensionBehaviorDeliverImmediately);
  129. savePressed();
  130. }