-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tweak.xm
58 lines (51 loc) · 1.85 KB
/
Tweak.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
#import <UIAlertView+Blocks.h>
static BOOL tapConfirmation = NO;
static NSMutableDictionary *plist;
// Photos DoubleTab Confirmation
%hook IGFeedPhotoView
-(void)onDoubleTap:(id)fp8{
if (tapConfirmation) {
UIAlertView *alert = [[UIAlertView alloc] init];
[alert setMessage:@"Like Image?"];
[alert setDelegate:self];
[alert addButtonWithTitle:@"No"];
[alert addButtonWithTitle:@"Yes"];
[alert show];
[alert release];
[alert showWithCompletion:^(UIAlertView *alertView, NSInteger buttonIndex) {
if (buttonIndex == 1) %orig;
}];
}
else %orig;
}
%end
// Video DoubleTab Confirmation
%hook IGFeedItemVideoView
-(void)onDoubleTap:(id)fp8{
if (tapConfirmation) {
UIAlertView *alert = [[UIAlertView alloc] init];
[alert setMessage:@"Like Video?"];
[alert setDelegate:self];
[alert addButtonWithTitle:@"No"];
[alert addButtonWithTitle:@"Yes"];
[alert show];
[alert release];
[alert showWithCompletion:^(UIAlertView *alertView, NSInteger buttonIndex) {
if (buttonIndex == 1) %orig;
}];
}
else %orig;
}
%end
static void reloadPrefs() {
[plist release];
plist = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.f0u4d.instaconfirm.plist"];
tapConfirmation = [[plist objectForKey:@"tapConfirmation"] boolValue];
}
static void PreferencesChanges(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
reloadPrefs();
}
%ctor {
reloadPrefs();
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)PreferencesChanges, CFSTR("com.f0u4d.instaconfirm.preferences-changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
}