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 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #define kBundlePath @"/Library/MobileSubstrate/DynamicLibraries/AVLockBundle.bundle"
  2. @interface SBOrientationLockManager
  3. +(SBOrientationLockManager *)sharedInstance;
  4. -(bool)isUserLocked;
  5. -(void)lock;
  6. -(void)unlock;
  7. @end
  8. @interface AVTransportControlsView
  9. -(void)addSubview:(id)arg1;
  10. @property CGRect frame;
  11. @end
  12. static bool firstrun = true;
  13. %hook AVTransportControlsView
  14. -(void)layoutSubviews{
  15. %orig;
  16. if(firstrun){
  17. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  18. [button addTarget:self action:@selector(orientationButtonPressed)
  19. forControlEvents:UIControlEventTouchUpInside];
  20. NSBundle *bundle = [[NSBundle alloc] initWithPath:kBundlePath];
  21. NSString *imagePath = [bundle pathForResource:@"Test" ofType:@"png"];
  22. UIImage *img = [UIImage imageWithContentsOfFile:imagePath];
  23. [button setImage:img forState:UIControlStateNormal];
  24. [button setImage:img forState:UIControlStateHighlighted];
  25. [button setImage:img forState:UIControlStateSelected];
  26. button.contentMode = UIViewContentModeScaleToFill;
  27. button.frame = CGRectMake(0, 0, img.size.width, img.size.height);
  28. [self addSubview:button];
  29. firstrun = false;
  30. }
  31. }
  32. -(void)dealloc{
  33. %orig;
  34. firstrun = true;
  35. }
  36. %new
  37. -(void)orientationButtonPressed{
  38. if([[%c(SBOrientationLockManager) sharedInstance] isUserLocked]){
  39. [[%c(SBOrientationLockManager) sharedInstance] unlock];
  40. }else{
  41. [[%c(SBOrientationLockManager) sharedInstance] lock];
  42. }
  43. }
  44. %end