objective-cjailbreakspringboard

iOS 7 Jailbreak Tweak need help pulling methods from one header into a %hook of another


Ok so I just recently (within the last couple of months) started playing around with JB tweak dev and am slowly putting the pieces together from opensource that I'm finding on git. However, I have hit somewhat of a coders wall. What I am trying to do is create a tweak that when I go to launch an app from the SB, before it launches the apps alpha float value animates to 0.0 with duration of 1 second. The problem I'm having is I cannot for the life of me(and I have scoured the internet, and I'm sure it's right in front of me I just am not seeing it for some reason) find any documentation on how to get methods or properties from another SB header implanted into a %hook of another header.

I need to get -(id)_iconImageView out of SBIconView.h and utilize it in a %hook into -(void)launchFromLocation:(int)location from SBApplicationIcon.h

I had initially got this to partially work just within the SBIconView.h by using touchesEnded but by the time the animation had finished doing its job, it would throw the icons into jitter mode and so I could 0.0 out all of my apps alpha values but not launch any of them... So I must find a way to utilize -(id)_iconImageView in SBApplicationIcon.h to get my desired result.

Any and all help or input is greatly appreciated!!! Thank you for your time.

This is my current code

enter code here

#import <AudioToolBox/AudioToolBox.h>


#define kBundlePath @"/Library/MobileSubstrate/DynmaicLibraries/com.cramage.LaunchNotifier"



@interface SBApplicationIcon
- (void)launchFromLocation:(int)arg;
@end

@interface SBIconView : UIView
-(id)_iconImageView;
-(float)iconImageAlpha;
+ (id)_jitterTransformAnimation;
+ (id)_jitterPositionAnimation;
+ (int)_defaultIconFormat;
@end


%hook SBApplicationIcon
-(void)launchFromLocation:(int)location
{

    SBIconView *sbic=[objc_getClass("SBIconView") _iconImageView];

    //NSString *message = [NSString stringWithFormat:@"%1.1f", [sbic iconImageAlpha]];
    //UIAlertView *alert2 = [[UIAlertView alloc]initWithTitle:@"Touch" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    //[alert2 show];
    //[alert2 release];

    //[NSThread sleepForTimeInterval:4.0];

    //%orig(location);

    NSURL *fileURL = [NSURL URLWithString:@"/System/Library/Audio/UISounds/play.caf"]; // see list below
    SystemSoundID soundID;
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)fileURL,&soundID);
    AudioServicesPlaySystemSound(soundID);



    //_iconImageView2.alpha = 1.0;




    UIView* iconImageView1 = [sbic _iconImageView];
    [UIView animateWithDuration:1.0 animations:^{

        iconImageView1.alpha = 0.0;


    }
    completion:^(BOOL finished){
       %orig(location);
    }];




}

%end

Solution

  • Ok so I figured it out...

    What I ended up having to do was defining iconImageView1 as a UIView outside of the %hook blocks and hooking into touchEnded and assigning iconImageView1 to _iconImageView. Than I could call that up in the hook for launchFromLocation

    coding looks something like this just a lot more cleaned up. I've been working with the hooking trying to learn something else so a lot of it is commented out but it really isn't that hard to follow.

    #import <AudioToolBox/AudioToolBox.h>
    #import <CoreGraphics/CoreGraphics.h>
    
    
    #define kBundlePath @"/Library/MobileSubstrate/DynmaicLibraries/com.cramage.LaunchNotifier"
    
    @interface SBApplicationIcon
    - (void)launchFromLocation:(int)arg;
    @end
    
    @interface SBLockViewOwner
    //+(id)sharedInstance;
    -(void)setShowingDeviceLock:(BOOL)lock;
    @end
    
    @interface SBIconView
    -(id)_iconImageView;
    -(void)touchesBegan:(id)began withEvent:(id)event;
    -(void)touchesEnded:(id)ended withEvent:(id)event;
    @end
    
    //static UIView* iconImageView1;
    //static BOOL isLaunching;
    
    //%hook SBIconView
    
    //-(void)touchesEnded:(id)ended withEvent:(id)event{
        //if (!isLaunching){
            //%orig;
        //}
    //}
    
    //-(void)touchesBegan:(id)began withEvent:(id)event{
        //if (!isLaunching){
            //iconImageView1 = [self _iconImageView];
            //%orig;
        //}
    //}
    //%end
    
    %hook SBApplicationIcon
    
    
    -(void)launchFromLocation:(int)location{
        //isLaunching = TRUE;
    
        SBLockViewOwner *sblvo = objc_getClass("SBLockViewOwner");
    
        //int state = TRUE;
        BOOL lock = TRUE;
        //sbdlc -(BOOL)_shouldLockDeviceNow = TRUE;
        [sblvo setShowingDeviceLock:(BOOL)lock];
    
    
        NSURL *fileURL = [NSURL URLWithString:@"/System/Library/Audio/UISounds/play.caf"]; // see list below
        SystemSoundID soundID;
        AudioServicesCreateSystemSoundID((__bridge CFURLRef)fileURL,&soundID);
        AudioServicesPlaySystemSound(soundID);
    
        //CGSize newBounds = CGSizeMake(iconImageView1.frame.size.width/4,iconImageView1.frame.size.height/4);
        //iconImageView1.backgroundColor = [UIColor blueColor];
    
        //[sbdlc _setLockState:(int)state];
    
        //CGFloat direction = 1.0f;  // -1.0f to rotate other way
        //iconImageView1.transform = CGAffineTransformIdentity;
        //iconImageView1.transform1 = CGAffineTransformScale;
        //[UIView animateKeyframesWithDuration:5.0 delay:0.0
            //options:UIViewKeyframeAnimationOptionCalculationModePaced //| UIViewAnimationOptionCurveEaseInOut
            //animations:^{
    
                //[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.0 animations:^{
                    //iconImageView1.transform = CGAffineTransformMakeScale(5.25, 0.001);
                //}];
                //[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.0 animations:^{
                    //iconImageView1.transform = CGAffineTransformMakeRotation(180);
                //}];
                //[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.0 animations:^{
                    //iconImageView1.transform = CGAffineTransformMakeRotation(180);
                //}];
                //[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.0 animations:^{
                    //iconImageView1.transform = CGAffineTransformIdentity;
                //}];
    
    
    
            //}
            //completion:^(BOOL finished) {
                //isLaunching = FALSE;
                //%orig(location);
            //}];
    
    
    }
    
    %end