Coder Social home page Coder Social logo

jridgewell / activityloader Goto Github PK

View Code? Open in Web Editor NEW
2.0 6.0 0.0 1000 KB

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

Home Page: http://jridgewell.github.com/ActivityLoader/

License: MIT License

Objective-C 100.00%

activityloader's Introduction

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.