diff --git a/DuplexCalendar.plist b/DuplexCalendar.plist new file mode 100644 index 0000000..10dc654 --- /dev/null +++ b/DuplexCalendar.plist @@ -0,0 +1 @@ +{ Filter = { Bundles = ( "com.apple.springboard" ); }; } diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..103e6a1 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ + +GO_EASY_ON_ME = 1 + +ARCHS = arm64 armv7 + +include $(THEOS)/makefiles/common.mk + +TWEAK_NAME = DuplexCalendar +DuplexCalendar_FILES = Tweak.xm +DuplexCalendar_FRAMEWORKS = CoreTelephony AudioToolbox + +include $(THEOS_MAKE_PATH)/tweak.mk + +after-install:: + install.exec "killall -9 SpringBoard" +SUBPROJECTS += duplexcalendarprefs +include $(THEOS_MAKE_PATH)/aggregate.mk diff --git a/Tweak.xm b/Tweak.xm new file mode 100644 index 0000000..f468603 --- /dev/null +++ b/Tweak.xm @@ -0,0 +1,147 @@ +#define kScreenWidth [[UIScreen mainScreen] bounds].size.width +#import +#import +@interface SBTodayTableHeaderView : UIView +-(NSString *)lunarDateHeaderString; +@end + +@interface SBFLockScreenDateView : UIView +@property (nonatomic, assign) UILabel *duplexCalendarLabel; +@property (nonatomic, assign) SBTodayTableHeaderView *todayHeaderView; +@property (nonatomic, assign) NSString *todayHeaderViewText; +@property bool dateHidden; +-(id)_dateFont; +-(id)_dateColor; +-(BOOL)isDateHidden; +-(void)layoutDuplexCalendarLabel; +@end + + +@interface _UILegibilityView : UIView +@end + +@interface _UILegibilityLabel : _UILegibilityView +@property (nonatomic, assign) NSString* string; +@property (nonatomic, assign) UIFont* font; + +@end + +extern "C" CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void); +static NSString *myObserver=@"duplexcalendarObserver"; +static NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.duplexcalendarprefs.plist"; +static NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath]; + +static void savePressed(){ + prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath]; +} + +static void savePressed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo){ + prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath]; +} + +static SBTodayTableHeaderView *stattodayHeaderView; +static float originx = 0.0; +static float originy = 0.0; +static float sizewidth = 0.0; +static float sizeheight = 0.0; + +%hook SBTodayTableHeaderView +-(SBTodayTableHeaderView *)initWithFrame:(CGRect)arg1{ + stattodayHeaderView = %orig(); + return stattodayHeaderView; +} +%end + +%hook SBFLockScreenDateView +%property (nonatomic, assign) UILabel *duplexCalendarLabel; +%property (nonatomic, assign) NSString *todayHeaderViewText; +-(SBFLockScreenDateView *)initWithFrame:(id)arg1{ + SBFLockScreenDateView *origself = %orig(arg1); + if(!self.duplexCalendarLabel){ + self.duplexCalendarLabel = [[UILabel alloc] initWithFrame:CGRectMake(originx-50, originy + 19, sizewidth+100, sizeheight)]; + self.duplexCalendarLabel.font = [[self _dateFont] fontWithSize:16]; + [self addSubview:self.duplexCalendarLabel]; + self.duplexCalendarLabel.textColor = [self _dateColor]; + self.duplexCalendarLabel.textAlignment = 1; + } + return origself; +} + +%new +-(void)layoutDuplexCalendarLabel{ + NSString *offsetXTextField = [prefs objectForKey:@"offsetXTextField"]; + NSString *offsetYTextField = [prefs objectForKey:@"offsetYTextField"]; + NSString *FontSizeTextField = [prefs objectForKey:@"FontSizeTextField"]; + + if(originx <= 0.0) + { + UILabel *originalLabel = MSHookIvar(self, "_dateLabel"); + originx = originalLabel.frame.origin.x; + originy = originalLabel.frame.origin.y; + sizewidth = originalLabel.frame.size.width; + sizeheight = originalLabel.frame.size.height; + } + [self.duplexCalendarLabel setFrame:CGRectMake(originx-50+ [offsetXTextField floatValue], originy + 19 + [offsetYTextField floatValue], sizewidth+100, sizeheight)]; + UIFont *font = self.duplexCalendarLabel.font; + if([FontSizeTextField floatValue] == 0){ + self.duplexCalendarLabel.font = [font fontWithSize:16.0]; + }else{ + self.duplexCalendarLabel.font = [font fontWithSize:[FontSizeTextField floatValue]]; + } + if(self.duplexCalendarLabel){ + if([self isDateHidden]){ + self.duplexCalendarLabel.hidden = true; + }else{ + self.duplexCalendarLabel.hidden = false; + } + } +} + +-(void)_updateLabels{ + [self layoutDuplexCalendarLabel]; + if(!self.todayHeaderViewText){ + self.todayHeaderViewText = [stattodayHeaderView lunarDateHeaderString]; + } + self.duplexCalendarLabel.text = self.todayHeaderViewText; + + + %orig; + +} +-(void)_layoutDateLabel { + [self layoutDuplexCalendarLabel]; + %orig; + _UILegibilityLabel *originalLegibilityLabel = MSHookIvar<_UILegibilityLabel *>(self, "_legibilityDateLabel"); + [originalLegibilityLabel setFrame:CGRectMake(originx, originy - 3, sizewidth, sizeheight)]; +} +-(void)updateFormat{ + [self layoutDuplexCalendarLabel]; + %orig; +} +-(void)layoutSubviews { + [self layoutDuplexCalendarLabel]; + %orig; +} + + +-(void)setDateHidden:(bool)arg1{ + %orig(arg1); + + if(self.duplexCalendarLabel){ + self.duplexCalendarLabel.hidden = arg1; + } +} + + +%end + + +%ctor{ + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), + (void*)myObserver, + savePressed, + CFSTR("duplexcalendar.savepressed"), + NULL, + CFNotificationSuspensionBehaviorDeliverImmediately); + savePressed(); +} diff --git a/control b/control new file mode 100644 index 0000000..f7b1df6 --- /dev/null +++ b/control @@ -0,0 +1,9 @@ +Package: com.gilshahar7.duplexcalendar +Name: DuplexCalendar +Depends: mobilesubstrate +Version: 1.0 +Architecture: iphoneos-arm +Description: Add the alternate calendar label to the LockScreen on iOS 9. +Maintainer: gilshahar7 +Author: gilshahar7 +Section: Tweaks diff --git a/duplexcalendarprefs/DCPRootListController.h b/duplexcalendarprefs/DCPRootListController.h new file mode 100644 index 0000000..10f31b1 --- /dev/null +++ b/duplexcalendarprefs/DCPRootListController.h @@ -0,0 +1,5 @@ +#import + +@interface DCPRootListController : PSListController + +@end diff --git a/duplexcalendarprefs/DCPRootListController.m b/duplexcalendarprefs/DCPRootListController.m new file mode 100644 index 0000000..67a3299 --- /dev/null +++ b/duplexcalendarprefs/DCPRootListController.m @@ -0,0 +1,40 @@ +#import +#include "DCPRootListController.h" + +@implementation DCPRootListController + +- (id)readPreferenceValue:(PSSpecifier*)specifier { + NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]]; + NSMutableDictionary *settings = [NSMutableDictionary dictionary]; + [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]]; + return (settings[specifier.properties[@"key"]]) ?: specifier.properties[@"default"]; +} + +- (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier { + NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]]; + NSMutableDictionary *settings = [NSMutableDictionary dictionary]; + [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]]; + [settings setObject:value forKey:specifier.properties[@"key"]]; + [settings writeToFile:path atomically:YES]; + CFStringRef notificationName = (CFStringRef)specifier.properties[@"PostNotification"]; + if (notificationName) { + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), notificationName, NULL, NULL, YES); + } +} + +- (NSArray *)specifiers { + if (!_specifiers) { + _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain]; + } + + return _specifiers; +} + +-(void)save +{ + [self.view endEditing:YES]; + CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("duplexcalendar.savepressed"), NULL, NULL, YES); +} + + +@end diff --git a/duplexcalendarprefs/Makefile b/duplexcalendarprefs/Makefile new file mode 100644 index 0000000..b100ffa --- /dev/null +++ b/duplexcalendarprefs/Makefile @@ -0,0 +1,13 @@ +include $(THEOS)/makefiles/common.mk + +BUNDLE_NAME = DuplexCalendarPrefs +DuplexCalendarPrefs_FILES = DCPRootListController.m +DuplexCalendarPrefs_INSTALL_PATH = /Library/PreferenceBundles +DuplexCalendarPrefs_FRAMEWORKS = UIKit +DuplexCalendarPrefs_PRIVATE_FRAMEWORKS = Preferences + +include $(THEOS_MAKE_PATH)/bundle.mk + +internal-stage:: + $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) + $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/DuplexCalendarPrefs.plist$(ECHO_END) diff --git a/duplexcalendarprefs/Resources/Info.plist b/duplexcalendarprefs/Resources/Info.plist new file mode 100644 index 0000000..d49ef6e --- /dev/null +++ b/duplexcalendarprefs/Resources/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + DuplexCalendarPrefs + CFBundleIdentifier + com.gilshahar7.duplexcalendarprefs + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSPrincipalClass + DCPRootListController + + diff --git a/duplexcalendarprefs/Resources/Root.plist b/duplexcalendarprefs/Resources/Root.plist new file mode 100644 index 0000000..6e44499 --- /dev/null +++ b/duplexcalendarprefs/Resources/Root.plist @@ -0,0 +1,69 @@ + + + + + items + + + cell + PSGroupCell + label + DuplexCalendar's Options + + + cell + PSEditTextCell + placeholder + 0 + bestGuess + 0 + defaults + com.gilshahar7.duplexcalendarprefs + key + offsetXTextField + label + X Offset: + + + cell + PSEditTextCell + placeholder + 0 + bestGuess + 0 + defaults + com.gilshahar7.duplexcalendarprefs + key + offsetYTextField + label + Y Offset: + + + cell + PSEditTextCell + placeholder + 16 + bestGuess + 16 + defaults + com.gilshahar7.duplexcalendarprefs + isDecimalPad + + key + FontSizeTextField + label + Font Size: + + + cell + PSButtonCell + label + Save + action + save + + + title + DuplexCalendar + + diff --git a/duplexcalendarprefs/entry.plist b/duplexcalendarprefs/entry.plist new file mode 100644 index 0000000..b4ea673 --- /dev/null +++ b/duplexcalendarprefs/entry.plist @@ -0,0 +1,21 @@ + + + + + entry + + bundle + DuplexCalendarPrefs + cell + PSLinkCell + detail + DCPRootListController + icon + icon.png + isController + + label + DuplexCalendarPrefs + + + diff --git a/packages/com.gilshahar7.duplexcalendar_1.0_iphoneos-arm.deb b/packages/com.gilshahar7.duplexcalendar_1.0_iphoneos-arm.deb new file mode 100644 index 0000000..a85870d Binary files /dev/null and b/packages/com.gilshahar7.duplexcalendar_1.0_iphoneos-arm.deb differ