Browse Source

Add files via upload

master
Gil Shahar 6 years ago
parent
commit
19a226e8a8
No account linked to committer's email address
5 changed files with 81 additions and 0 deletions
  1. +1
    -0
      AVLock.plist
  2. +17
    -0
      Makefile
  3. BIN
      Resources/Test@2x.png
  4. +54
    -0
      Tweak.xm
  5. +9
    -0
      control

+ 1
- 0
AVLock.plist View File

@@ -0,0 +1 @@
{ Filter = { Bundles = ( "com.apple.AVKit", "com.apple.springboard" ); }; }

+ 17
- 0
Makefile View File

@@ -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"

BIN
Resources/Test@2x.png View File

Before After
Width: 44  |  Height: 44  |  Size: 7.7KB

+ 54
- 0
Tweak.xm View File

@@ -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

+ 9
- 0
control View File

@@ -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

Loading…
Cancel
Save