This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpringBoard.xm
84 lines (69 loc) · 3.3 KB
/
SpringBoard.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#import "SpringBoard.h"
%hook SBLockScreenManager
- (void)_finishUIUnlockFromSource:(int)source withOptions:(id)options {
%orig;
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL hasRunBefore = [fileManager fileExistsAtPath:firstRunFile];
if ( ! hasRunBefore) {
[UIAlertView showWithTitle:nil
message:@"Thanks for installing Bluetooth Renamer. I'm always on Twitter if you have suggestions/problems. Consider a follow?"
cancelButtonTitle:@"No Thanks"
otherButtonTitles:@[@"Okay Cool"]
tapBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
if (buttonIndex != [alertView cancelButtonIndex]) {
HBLogDebug(@"User accepted");
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
if(granted) {
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
HBLogDebug(@"Accounts: %@", accountsArray);
NSMutableArray *accs = [NSMutableArray array];
for(ACAccount *acc in accountsArray) {
[accs addObject:[NSString stringWithFormat:@"@%@", acc.username]];
}
[accs addObject:@"All Accounts!"];
HBLogDebug(@"Formatted Accounts: %@", accs);
if ([accountsArray count] > 1) {
dispatch_async(dispatch_get_main_queue(), ^{
[UIAlertView showWithTitle:@"Which Account?"
message:@"Select an account to follow with."
cancelButtonTitle:@"Cancel"
otherButtonTitles:[accs copy]
tapBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
if (buttonIndex != [alertView cancelButtonIndex]) {
if (buttonIndex == [accs count]) {
HBLogDebug(@"All button clicked!");
for (ACAccount *twitterAccount in accountsArray) {
followMeOnTwitter(twitterAccount);
}
} else {
ACAccount *twitterAccount = [accountsArray objectAtIndex:buttonIndex-1];
followMeOnTwitter(twitterAccount);
}
}
}];
});
} else if([accountsArray count] == 1) {
ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
followMeOnTwitter( twitterAccount );
}
}
}];
}
}];
hasRunBefore = [fileManager createFileAtPath:firstRunFile contents:nil attributes:nil];
HBLogDebug(@"Setting First Run To True: %@", hasRunBefore ? @"YES" : @"NO");
}
}
%end
%ctor {
CFNotificationCenterAddObserver(
CFNotificationCenterGetDarwinNotifyCenter(),
NULL,
(CFNotificationCallback)rebootDevice,
(CFStringRef) @"com.tapsharp.bluetoothrenamer/rebootDevice",
NULL,
CFNotificationSuspensionBehaviorCoalesce
);
}