Skip to content

A MobileSubstrate library for adding custom UIActions (iOS 6+ share actions) to all apps.

License

Notifications You must be signed in to change notification settings

jridgewell/ActivityLoader

Repository files navigation

ActivityLoader

A library for adding custom UIActions (iOS 6+ share actions) to all apps. Requires a jailbroken iOS.

Instapaper: Read Later using ActivityLoader

The Quick Way

Add the following repo to your Cydia sources: http://jridgewell.github.io/ActivityLoader/cydia/

Search for ActivityLoader, and install!

What?

Implementing this library will allow you to add any UIActivity to any app that uses UIActivityViewController. That's all the stock Apple apps, right off the bat! I've implemented Instapaper as an example (using @marianoabdala's ZYInstapaperActivity).

How do I do it?

  1. Download the lib and .h files.
  2. Create a subclass of UIActivity that implements the protocol.
  3. Do whatever you want.

MyActivity.h

#import <UIKit/UIKit.h>
#import <ActivityLoader/ActivityLoader.h>

@interface MyActivity : UIActivity <ALActivity>

@property (strong, atomic) NSArray *activityItems;

// Required by <ALActivity>
+ (instancetype)instance;
+ (void)load;


// Required by UIActivity
- (NSString *)activityType;
- (NSString *)activityTitle;
- (UIImage *)activityImage;
- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems;
- (void)prepareWithActivityItems:(NSArray *)activityItems;
// Implement ONE AND ONLY ONE of the following.
// - (UIViewController *)activityViewController;
- (void)performActivity;

@end

MyActivity.m

#import "MyActivity.h"

@implementation MyActivity

#pragma mark - MyActivity <ALActivity>

+ (instancetype)instance {
    static dispatch_once_t pred = 0;
    __strong static id _instance = nil;
    
    dispatch_once(&pred, ^{
        _instance = [self alloc];
        _instance = [_instance init];
    });
    
    return _instance;
}

+ (void)load {
	id instance = [MyActivity instance];
    [[ALActivityLoader sharedInstance] registerActivity:instance
                                             identifier:[instance activityType]
                                                  title:[instance activityTitle]];
}

#pragma mark - MyActivity : UIActivity


- (NSString *)activityTitle {
    return NSLocalizedString(@"My Super Cool Share Activity", @"");
}

- (NSString *)activityType {
    return @"com.example.myactivity";
}

- (UIImage *)activityImage {
    return [UIImage imageNamed:@"icon"];
}

- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems {
    return YES;
}

- (void)prepareWithActivityItems:(NSArray *)items {
    self.activityItems = items;
}

- (void)performActivity {
    for (id activityItem in self.activityItems) {
        NSLog(@"%@", activityItem);
    }
}

@end

TODO

  1. Create an example project.
  2. Create:
    • Theos template
    • iOSOpenDev template
  3. More activities!

About

A MobileSubstrate library for adding custom UIActions (iOS 6+ share actions) to all apps.

Resources

License

Stars

Watchers

Forks

Packages

No packages published