Browse Source

Merge pull request #1 from mcproj/master

Add iOS8 support
pull/2/head
Gil Shahar 4 years ago
parent
commit
6fa3612b4d
No account linked to committer's email address
1 changed files with 30 additions and 6 deletions
  1. +30
    -6
      Tweak.xm

+ 30
- 6
Tweak.xm View File

@end @end


@interface SBFLockScreenDateView : UIView @interface SBFLockScreenDateView : UIView
@property (nonatomic, assign) UILabel *duplexCalendarLabel;
@property (nonatomic, retain) UILabel *duplexCalendarLabel;
@property (nonatomic, assign) NSString *todayHeaderViewText; @property (nonatomic, assign) NSString *todayHeaderViewText;
@property bool dateHidden; @property bool dateHidden;
-(id)_dateFont; -(id)_dateFont;
prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath]; prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
} }


static BOOL isiOS9 = NO;
static BOOL isiOS8Refreshed = NO;
static SBTodayTableHeaderView *stattodayHeaderView; static SBTodayTableHeaderView *stattodayHeaderView;
static SBFLockScreenDateView *lockScreenDateView;
static float originx = 0.0; static float originx = 0.0;
static float originy = 0.0; static float originy = 0.0;
static float sizewidth = 0.0; static float sizewidth = 0.0;
stattodayHeaderView = %orig(); stattodayHeaderView = %orig();
return stattodayHeaderView; return stattodayHeaderView;
} }

-(void)_layoutLunarDateLabel{
%orig;
if(isiOS9) return;
if(!isiOS8Refreshed) {
isiOS8Refreshed = YES;
[lockScreenDateView _updateLabels];
lockScreenDateView = nil;
}
}
%end %end


%hook SBFLockScreenDateView %hook SBFLockScreenDateView
%property (nonatomic, assign) UILabel *duplexCalendarLabel;
%property (nonatomic, retain) UILabel *duplexCalendarLabel;
%property (nonatomic, assign) NSString *todayHeaderViewText; %property (nonatomic, assign) NSString *todayHeaderViewText;
-(SBFLockScreenDateView *)initWithFrame:(id)arg1{ -(SBFLockScreenDateView *)initWithFrame:(id)arg1{
SBFLockScreenDateView *origself = %orig(arg1);
lockScreenDateView = %orig(arg1);
if(!self.duplexCalendarLabel){ if(!self.duplexCalendarLabel){
self.duplexCalendarLabel = [[UILabel alloc] initWithFrame:CGRectMake(originx-50, originy + 19, sizewidth+100, sizeheight)]; self.duplexCalendarLabel = [[UILabel alloc] initWithFrame:CGRectMake(originx-50, originy + 19, sizewidth+100, sizeheight)];
self.duplexCalendarLabel.font = [[self _dateFont] fontWithSize:16]; self.duplexCalendarLabel.font = [[self _dateFont] fontWithSize:16];
self.duplexCalendarLabel.textColor = [self _dateColor]; self.duplexCalendarLabel.textColor = [self _dateColor];
self.duplexCalendarLabel.textAlignment = 1; self.duplexCalendarLabel.textAlignment = 1;
} }
return origself;
return lockScreenDateView;
} }


%new %new
}else{ }else{
self.duplexCalendarLabel.font = [font fontWithSize:[FontSizeTextField floatValue]]; self.duplexCalendarLabel.font = [font fontWithSize:[FontSizeTextField floatValue]];
} }
if(self.duplexCalendarLabel){
if(isiOS9 && self.duplexCalendarLabel){
if([self isDateHidden]){ if([self isDateHidden]){
self.duplexCalendarLabel.hidden = true; self.duplexCalendarLabel.hidden = true;
}else{ }else{
-(void)setDateHidden:(bool)arg1{ -(void)setDateHidden:(bool)arg1{
%orig(arg1); %orig(arg1);


if(self.duplexCalendarLabel){
if(isiOS9 && self.duplexCalendarLabel){
self.duplexCalendarLabel.hidden = arg1; self.duplexCalendarLabel.hidden = arg1;
} }
} }


-(void)_setDateAlpha:(double)arg1{
%orig(arg1);

if(!isiOS9 && self.duplexCalendarLabel){
UILabel *originalLabel = MSHookIvar<UILabel *>(self, "_dateLabel");
self.duplexCalendarLabel.alpha = originalLabel.alpha;
}
}



%end %end


%end %end


%ctor{ %ctor{
if(@available(iOS 9.0, *)) isiOS9 = YES;
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
(void*)myObserver, (void*)myObserver,
savePressed, savePressed,

Loading…
Cancel
Save