Ask before casting to prevent you from accidentally hijacking the tv when you press the cast button.
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.

37 lines
1.5KB

  1. %hook MDXPlaybackRouteButtonController
  2. -(void)didPressButton:(id)arg1 {
  3. UIAlertController* alertController = [%c(UIAlertController) alertControllerWithTitle:@"Casting"
  4. message:@"Are you sure you want to start casting?"
  5. preferredStyle:UIAlertControllerStyleAlert];
  6. UIAlertAction* defaultAction = [%c(UIAlertAction) actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  7. %orig;
  8. }];
  9. UIAlertAction* noButton = [%c(UIAlertAction)
  10. actionWithTitle:@"Cancel"
  11. style:UIAlertActionStyleDefault
  12. handler: ^(UIAlertAction * action) {
  13. return;
  14. }];
  15. [alertController addAction:defaultAction];
  16. [alertController addAction:noButton];
  17. id rootViewController = [%c(UIApplication) sharedApplication].delegate.window.rootViewController;
  18. if([rootViewController isKindOfClass:[%c(UINavigationController) class]]) {
  19. rootViewController = ((UINavigationController *)rootViewController).viewControllers.firstObject;
  20. }
  21. if([rootViewController isKindOfClass:[%c(UITabBarController) class]]) {
  22. rootViewController = ((UITabBarController *)rootViewController).selectedViewController;
  23. }
  24. if ([rootViewController presentedViewController] != nil) {
  25. rootViewController = [rootViewController presentedViewController];
  26. }
  27. [rootViewController presentViewController:alertController animated:YES completion:nil];
  28. }
  29. %end