Skip to content

Commit 1f8e8d3

Browse files
committed
Initial Commit
1 parent ff65b5f commit 1f8e8d3

24 files changed

+2231
-3
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*/build*
2+
*Library/*
3+
*xcuserdata*
4+
*xccheckout*

Injection4Android.xcodeproj/project.pbxproj

+463
Large diffs are not rendered by default.

Injection4Android.xcodeproj/project.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Injection4Android/App.icns

357 KB
Binary file not shown.

Injection4Android/AppDelegate.h

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// AppDelegate.h
3+
// Injection4Android
4+
//
5+
// Created by John Holdsworth on 15/09/2017.
6+
// Copyright © 2017 John Holdsworth. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
@interface AppDelegate : NSObject <NSApplicationDelegate>
12+
13+
@property (weak) IBOutlet NSWindow *window;
14+
15+
- (void)error:(NSString *)format, ...;
16+
- (void)setBadge:(NSString *)badge;
17+
- (void)output:(NSString *)output;
18+
19+
@end
20+

Injection4Android/AppDelegate.m

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
//
2+
// AppDelegate.m
3+
// Injection4Android
4+
//
5+
// Created by John Holdsworth on 15/09/2017.
6+
// Copyright © 2017 John Holdsworth. All rights reserved.
7+
//
8+
9+
#import "AppDelegate.h"
10+
#import "Connection.h"
11+
12+
#import <WebKit/WebKit.h>
13+
14+
@interface AppDelegate () <WebPolicyDelegate>
15+
@property (weak) IBOutlet WebView *webView;
16+
@end
17+
18+
@implementation NSString (Replace)
19+
20+
- stringReplace:( NSString * _Nonnull)pattern withBlock:(NSString * _Nonnull (^)(NSArray<NSString *> *groups))block {
21+
NSError *error;
22+
NSRegularExpression *regexp = [[NSRegularExpression alloc] initWithPattern:pattern options:NSRegularExpressionAnchorsMatchLines error:&error];
23+
if (error)
24+
[NSAlert alertWithError:error];
25+
NSMutableString *out = [NSMutableString new];
26+
__block NSUInteger pos = 0;
27+
28+
[regexp enumerateMatchesInString:self options:0 range:NSMakeRange(0,self.length) usingBlock:
29+
^void (NSTextCheckingResult * _Nullable result, NSMatchingFlags flags, BOOL * _Nonnull stop) {
30+
NSRange range = result.range;
31+
[out appendString:[self substringWithRange:NSMakeRange(pos, range.location-pos)]];
32+
NSMutableArray *groups = [NSMutableArray new];
33+
for ( int i=0; i<=regexp.numberOfCaptureGroups ; i++ )
34+
[groups addObject:[self substringWithRange:[result rangeAtIndex:i]]];
35+
[out appendString:block( groups )];
36+
pos = range.location + range.length;
37+
}];
38+
39+
[out appendString:[self substringWithRange:NSMakeRange(pos, self.length-pos)]];
40+
return out;
41+
}
42+
43+
@end
44+
45+
@implementation AppDelegate
46+
47+
- (void)error:(NSString *)format, ... {
48+
va_list argp;
49+
va_start(argp, format);
50+
NSString *message = [[NSString alloc] initWithFormat:format arguments:argp];
51+
[self performSelectorOnMainThread:@selector(alert:) withObject:message waitUntilDone:NO];
52+
}
53+
54+
- (void)alert:(NSString *)msg {
55+
[self.window orderFront:self];
56+
[[NSAlert alertWithMessageText:@"Injection Plugin:"
57+
defaultButton:@"OK" alternateButton:nil otherButton:nil
58+
informativeTextWithFormat:@"%@", msg] runModal];
59+
// msgField.stringValue = msg;
60+
// [self.alertPanel orderFront:self];
61+
}
62+
63+
- (void)setBadge:(NSString *)badge {
64+
[[[NSApplication sharedApplication] dockTile] performSelectorOnMainThread:@selector(setBadgeLabel:)
65+
withObject:badge waitUntilDone:NO];
66+
}
67+
68+
- (void)output:(NSString *)output {
69+
dispatch_async(dispatch_get_main_queue(), ^{
70+
NSString *html = [output stringReplace:@"(^/[^:]+/([^/:]+)):" withBlock:^(NSArray<NSString *> *groups){
71+
return [NSString stringWithFormat:@"<a href=\"file://%@\">%@</a>:", groups[1], groups[2]];
72+
}];
73+
[self.webView.mainFrame loadHTMLString:[NSString stringWithFormat:@"<pre>%@</pre>", html] baseURL:nil];
74+
});
75+
}
76+
77+
- (void)webView:(WebView *)aWebView decidePolicyForNavigationAction:(NSDictionary *)actionInformation
78+
request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id < WebPolicyDecisionListener >)listener {
79+
if (request.URL.isFileURL)
80+
[[NSWorkspace sharedWorkspace] openURL:request.URL];
81+
else
82+
[listener use];
83+
}
84+
85+
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
86+
// Insert code here to initialize your application
87+
[Connection startSever:self];
88+
}
89+
90+
- (void)applicationWillTerminate:(NSNotification *)aNotification {
91+
// Insert code here to tear down your application
92+
}
93+
94+
95+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "mac",
5+
"size" : "16x16",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "mac",
10+
"size" : "16x16",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "mac",
15+
"size" : "32x32",
16+
"scale" : "1x"
17+
},
18+
{
19+
"idiom" : "mac",
20+
"size" : "32x32",
21+
"scale" : "2x"
22+
},
23+
{
24+
"idiom" : "mac",
25+
"size" : "128x128",
26+
"scale" : "1x"
27+
},
28+
{
29+
"idiom" : "mac",
30+
"size" : "128x128",
31+
"scale" : "2x"
32+
},
33+
{
34+
"idiom" : "mac",
35+
"size" : "256x256",
36+
"scale" : "1x"
37+
},
38+
{
39+
"idiom" : "mac",
40+
"size" : "256x256",
41+
"scale" : "2x"
42+
},
43+
{
44+
"idiom" : "mac",
45+
"size" : "512x512",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "mac",
50+
"size" : "512x512",
51+
"scale" : "2x"
52+
}
53+
],
54+
"info" : {
55+
"version" : 1,
56+
"author" : "xcode"
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

0 commit comments

Comments
 (0)