This repository was 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
Expand file tree
/
Copy pathWelcome.xm
More file actions
74 lines (60 loc) · 3.6 KB
/
Copy pathWelcome.xm
File metadata and controls
74 lines (60 loc) · 3.6 KB
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
#import "Shared.h"
NSString* kDefaultsFirstLaunchKey = @"shown_announcement_7";
NSString *kTwitterUsername = @"neoighodaro";
NSString *kWhatsappDarkModeBundleIdentifier = @"com.tapsharp.whatsappdarkmode";
@interface WANavigationController: UIViewController
- (void)openTwitterAccount:(NSString *)username;
@end
%group NEW_INSTALLATION_WELCOME
%hook WANavigationController
-(void)viewDidAppear:(BOOL)animated {
%orig;
NSNumber *shownMessage = [[NSUserDefaults standardUserDefaults] objectForKey:kDefaultsFirstLaunchKey
inDomain:kWhatsappDarkModeBundleIdentifier];
if (shownMessage != 0) return;
NSString *message = @"Thanks for installing WhatsApp Dark Mode.\n\n If you have any suggestions or bugs to report "
"send it to me on Twitter. This tweak is free but you can always consider donating a dollar "
"or more and following me on Twitter for updates.";
UIAlertController *alertCtrl = [UIAlertController alertControllerWithTitle:@"Welcome!"
message:message
preferredStyle:UIAlertControllerStyleAlert];
[alertCtrl addAction:[UIAlertAction actionWithTitle:@"Not Interested 😞" style:UIAlertActionStyleCancel handler:nil]];
[alertCtrl addAction:[UIAlertAction actionWithTitle:@"Follow @NeoIghodaro"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self openTwitterAccount:kTwitterUsername];
}]];
[alertCtrl addAction:[UIAlertAction actionWithTitle:@"Buy me coffee"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.paypal.me/oreogundipe"]];
}]];
[self presentViewController:alertCtrl animated:YES completion:nil];
}
%new
- (void)openTwitterAccount:(NSString *)username {
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tweetbot:"]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[@"tweetbot:///user_profile/" stringByAppendingString:username]]];
}
else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitterrific:"]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[@"twitterrific:///profile?screen_name=" stringByAppendingString:username]]];
}
else if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter:"]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[@"twitter://user?screen_name=" stringByAppendingString:username]]];
}
else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[@"https://mobile.twitter.com/" stringByAppendingString:username]]];
}
}
%end
%end
%ctor {
NSNumber *shownMessage = [[NSUserDefaults standardUserDefaults] objectForKey:kDefaultsFirstLaunchKey
inDomain:kWhatsappDarkModeBundleIdentifier];
if (shownMessage == 0) {
%init(NEW_INSTALLATION_WELCOME)
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES]
forKey:kDefaultsFirstLaunchKey
inDomain:kWhatsappDarkModeBundleIdentifier];
}
}