Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jridgewell/activityloader

A MobileSubstrate library for adding custom UIActions (iOS 6+ share actions) to all apps.
https://github.com/jridgewell/activityloader

Last synced: about 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

ActivityLoader
==============

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

![Instapaper: Read Later using ActivityLoader](http://jridgewell.github.io/ActivityLoader/resources/activityloader.png)

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](https://github.com/marianoabdala/ZYInstapaperActivity)).

How do I do it?
---------------

1. Download the [lib and .h files](http://jridgewell.github.io/ActivityLoader/resources/activityloader.zip).
2. Create a subclass of UIActivity that implements the protocol.
3. Do whatever you want.

MyActivity.h
```objective-c
#import
#import

@interface MyActivity : UIActivity

@property (strong, atomic) NSArray *activityItems;

// Required by
+ (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
```objective-c
#import "MyActivity.h"

@implementation MyActivity

#pragma mark - MyActivity

+ (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!