-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweak.xm
67 lines (49 loc) · 1.75 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
59
60
61
62
63
64
65
66
67
#import "HarlemShakeTVTweak_header.h"
/*
This tweak was created out of boredom and for my good friend David from @thejailbreakhub.
Copyright 2019 J.K. Hayslip (@iKilledAppl3) & ToxicAppl3 INSDC./iKilledAppl3 LLC.
December, 29, 2019 was a fun day for us all!
Anyways enjoy and remember not to spoil yourself!
*/
// the icon class we need to hook it so we can modify it's code!
%hook HBRootCell
/// Lets modify this method because why not make idle mode useful?
-(void)_enterIdleMode {
if (kEnabled) { // make the icons dance if it's enabled
%orig;
[self setupHarlemShake]; // created a new method so....
}
else {
%orig;
}
}
// new method :P
%new -(void)setupHarlemShake {
lonerView = self; // self = HBRootCell class :P
if (!animating) {
harlemShake = [[VLMHarlemShake alloc] initWithLonerView:lonerView];
}
if (animating) {
return;
}
if (lonerView != nil) {
animating = YES;
}
[harlemShake shakeWithCompletion:^{ // this will shake the icons view.
animating = NO;
harlemShake = nil;
}];
}
%end
// Load preferences to make sure changes are written to the plist
static void loadPrefs() {
NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:PLIST_PATH];
//our preference values that write to a plist file when a user selects something
kEnabled = [([prefs objectForKey:@"kEnabled"] ?: @(NO)) boolValue];
}
// our constructor
// we use this for our preferences call back to see if the user has updated the value or not.
%ctor {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback) loadPrefs, CFSTR("com.ikilledappl3.harlemShaketv.prefschanged"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
loadPrefs();
}