diff --git a/AVLock.plist b/AVLock.plist new file mode 100644 index 0000000..ad30a27 --- /dev/null +++ b/AVLock.plist @@ -0,0 +1 @@ +{ Filter = { Bundles = ( "com.apple.AVKit", "com.apple.springboard" ); }; } diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..02fe8b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +ARCHS = armv7 arm64 + +include $(THEOS)/makefiles/common.mk + +TWEAK_NAME = AVLock +AVLock_FILES = Tweak.xm +AVLock_FRAMEWORKS = UIKit + +include $(THEOS_MAKE_PATH)/tweak.mk + + +BUNDLE_NAME = AVLockBundle +AVLockBundle_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries +include $(THEOS)/makefiles/bundle.mk + +after-install:: + install.exec "killall -9 SpringBoard" diff --git a/Resources/Test@2x.png b/Resources/Test@2x.png new file mode 100644 index 0000000..cb1ed0a Binary files /dev/null and b/Resources/Test@2x.png differ diff --git a/Tweak.xm b/Tweak.xm new file mode 100644 index 0000000..ec720b1 --- /dev/null +++ b/Tweak.xm @@ -0,0 +1,54 @@ +#define kBundlePath @"/Library/MobileSubstrate/DynamicLibraries/AVLockBundle.bundle" + + +@interface SBOrientationLockManager ++(SBOrientationLockManager *)sharedInstance; +-(bool)isUserLocked; +-(void)lock; +-(void)unlock; +@end + +@interface AVTransportControlsView +-(void)addSubview:(id)arg1; +@property CGRect frame; +@end + +static bool firstrun = true; + +%hook AVTransportControlsView +-(void)layoutSubviews{ +%orig; +if(firstrun){ + UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; + [button addTarget:self action:@selector(orientationButtonPressed) + forControlEvents:UIControlEventTouchUpInside]; + + NSBundle *bundle = [[NSBundle alloc] initWithPath:kBundlePath]; + NSString *imagePath = [bundle pathForResource:@"Test" ofType:@"png"]; + UIImage *img = [UIImage imageWithContentsOfFile:imagePath]; + + [button setImage:img forState:UIControlStateNormal]; + [button setImage:img forState:UIControlStateHighlighted]; + [button setImage:img forState:UIControlStateSelected]; + button.contentMode = UIViewContentModeScaleToFill; + button.frame = CGRectMake(0, 0, img.size.width, img.size.height); + [self addSubview:button]; + firstrun = false; +} +} + +-(void)dealloc{ +%orig; +firstrun = true; +} + +%new +-(void)orientationButtonPressed{ + if([[%c(SBOrientationLockManager) sharedInstance] isUserLocked]){ +[[%c(SBOrientationLockManager) sharedInstance] unlock]; +}else{ +[[%c(SBOrientationLockManager) sharedInstance] lock]; +} +} + +%end \ No newline at end of file diff --git a/control b/control new file mode 100644 index 0000000..af1ea1e --- /dev/null +++ b/control @@ -0,0 +1,9 @@ +Package: com.gilshahar7.avlock +Name: AVLock +Depends: mobilesubstrate +Version: 0.0.1 +Architecture: iphoneos-arm +Description: An awesome MobileSubstrate tweak! +Maintainer: gilshahar7 +Author: gilshahar7 +Section: Tweaks