-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTweak.xm
More file actions
328 lines (286 loc) · 11.3 KB
/
Tweak.xm
File metadata and controls
328 lines (286 loc) · 11.3 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
@interface NowPlayingArtPluginController : NSObject
- (id)view;
@end
@interface SBAwayView : UIView
-(id)topBar;
-(id)bottomBar;
-(id)_defaultDesktopImage;
@end
@interface SBAwayDateView : UIView
-(void)setPositon;
@end
@interface SBDeviceLockViewWithKeypad : UIView
@end
@interface SBAwayController : NSObject
-(id)sharedAwayController;
@end
@interface TPLCDTextView : UIView {}
-(void)setShadowColor:(UIColor *)fp8;
-(void)setText:(id)fp8;
-(void)setTextColor:(UIColor *)fp8;
-(void)setFont:(UIFont*)font;
- (void)setLCDTextFont:(id)arg1;
@end
CGPoint _priorPoint;
%hook SBAwayView
-(void)finishedAnimatingIn{
%orig;
UIView *&_backgroundView(MSHookIvar<UIView *>(self, "_backgroundView"));
[_backgroundView setUserInteractionEnabled:YES]; //Allows backbround to use gesture
[[self dateHeaderView] setPositon]; //reset the position of the date view to be below the larger clock
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(newUnlockStyleMover:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
//[_backgroundView addGestureRecognizer:panRecognizer] This can be used but is incompatible with LockHTML
[[self.subviews objectAtIndex:0] addGestureRecognizer:panRecognizer]; //Add gesture to the background view or LockHTML's z order organizer
[panRecognizer release];
panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(newUnlockStyleMover:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
[[self bottomBar] addGestureRecognizer:panRecognizer]; //Lockbar
[panRecognizer release];
panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(newUnlockStyleMover:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
[[self topBar] addGestureRecognizer:panRecognizer]; //Clock and Date View's
[panRecognizer release];
[self _setTopBarImage:[self getUIImageForControls] shadowColor:[UIColor clearColor]];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:[UIDevice currentDevice]];
}
%new
- (void) orientationChanged:(NSNotification *)note
{
[[self dateHeaderView] setPositon];
}
%new
- (void)newUnlockStyleMover:(UIPanGestureRecognizer *)sender {
UIView *&_lockBar(MSHookIvar<UIView *>(self, "_lockBar"));
float width = ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height;
CGPoint point = [sender locationInView:sender.view.superview];
if (sender.state == UIGestureRecognizerStateChanged){
UIImage *_defaultDesktopImage = [self _defaultDesktopImage];
for(UIView *obj in [self subviews]){
if(obj != [self.subviews objectAtIndex:0]){
CGPoint center = obj.center;
if(center.x < width/2)
center.x += (point.x - _priorPoint.x)/3;
else
center.x += point.x - _priorPoint.x;
obj.center = center;
}
}
}
else if (sender.state == UIGestureRecognizerStateEnded){
if(_lockBar.center.x < width){
for(UIView *obj in [self subviews]){
if(obj != [self.subviews objectAtIndex:0]){
CGPoint center = obj.center;
center.x = width/2;
[UIView animateWithDuration:0.6
animations:^{
obj.center = center;
}
completion:^(BOOL finished){
}];
}
}
}
else{
for(UIView *obj in [self subviews]){
if(obj != [self.subviews objectAtIndex:0]){
CGPoint center = obj.center;
center.x = width+(width/2);
[UIView animateWithDuration:0.2
animations:^{
obj.center = center;
}
completion:^(BOOL finished){
}];
}
}
if([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/Library/MobileSubstrate/DynamicLibraries/AndroidLock.dylib"]] == TRUE && [[[NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.zmaster.AndroidLock.plist"] objectForKey:@"Enable"] boolValue] == TRUE){
[[%c(SBAwayController) sharedAwayController] unlockWithSound:TRUE bypassPinLock:[[%c(SBDeviceLockController) sharedController] isPasswordProtected]];
CGPoint center = _lockBar.center;
center.x = width/2;
_lockBar.center = center;
}
else{
//[[%c(SBAwayController) sharedAwayController] _sendToDeviceLockOwnerSetShowingDeviceLock:TRUE animated:FALSE];
[[[[%c(SBAwayController) sharedAwayController] awayView] bottomBar] setHidden:YES];
[[[[%c(SBAwayController) sharedAwayController] awayView] bottomBar] unlock];
}
}
}
_priorPoint = point;
}
-(id)_topBarLCDImage{
return [self _topBarLCDControlsImage];
}
- (id)_topBarLCDControlsImage{
return [self getUIImageForControls];
}
%new
-(UIImage*)getUIImageForControls{
UIGraphicsBeginImageContextWithOptions(CGSizeMake([[UIScreen mainScreen] bounds].size.width, 133), NO, 0.0);
UIImage *blank = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return blank;
}
- (void)_setPluginController:(id)arg1{
%orig(arg1);
if ([arg1 isMemberOfClass:NSClassFromString(@"NowPlayingArtPluginController")]){
id pluginController = [self currentAwayPluginController];
if ([pluginController isMemberOfClass:NSClassFromString(@"NowPlayingArtPluginController")]){
UIView *pluginView = [(NowPlayingArtPluginController *)pluginController view];
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(newUnlockStyleMover:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
//[panRecognizer setDelegate:self];
[pluginView addGestureRecognizer:panRecognizer];
[panRecognizer release];
for(UIView *obj in [[(NowPlayingArtPluginController *)pluginController view] subviews]){
if([obj isKindOfClass:[UIImageView class]]){
if([[UIScreen mainScreen] bounds].size.width == 320)
obj.frame = CGRectMake(0, 0, 280, 280);
}
if([obj isKindOfClass:NSClassFromString(@"NowPlayingReflectionView")]){
[obj removeFromSuperview];
}
}
if([[UIScreen mainScreen] bounds].size.width == 320)
pluginView.frame = CGRectMake(20,173,280,280);
}
}
}
%end
%hook SBAwayController
- (void)undimScreen:(BOOL)arg1{
//Slide Lockscreen back to default position after the screen sleeps
float width = ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height;
[[[[%c(SBAwayController) sharedAwayController] awayView] bottomBar] setHidden:NO];
for(UIView *obj in [[self awayView] subviews]){
if(obj != [[[self awayView] subviews] objectAtIndex:0]){
CGPoint center = obj.center;
center.x = width/2;
[UIView animateWithDuration:0.6
animations:^{
obj.center = center;
}
completion:^(BOOL finished){
}];
}
}
%orig;
}
%end
%hook SBAwayDateView
-(void)setFrame:(CGRect)frame{
%orig;
TPLCDTextView *timeLabel = MSHookIvar<TPLCDTextView *>(self, "_timeLabel");
[timeLabel setLCDTextFont:[[timeLabel font] fontWithSize:96]];
[timeLabel setFrame:CGRectMake(timeLabel.frame.origin.x,timeLabel.frame.origin.y,timeLabel.frame.size.width,timeLabel.frame.size.height+60)];
[self setPositon];
}
%new
-(void)setPositon{
TPLCDTextView *dateLabel = MSHookIvar<TPLCDTextView *>(self, "_dateAndTetheringLabel");
[dateLabel setFrame:CGRectMake(dateLabel.frame.origin.x,100,dateLabel.frame.size.width,dateLabel.frame.size.height)];
}
- (void)setVisible:(BOOL)arg1{
%orig;
[self setPositon]; //attempt to keep date view in proper location
}
- (void)resizeAndPositionNowPlayingLabels{
UILabel *_nowPlayingTitleLabel = MSHookIvar<UILabel *>(self, "_nowPlayingTitleLabel");
UILabel *_nowPlayingArtistLabel = MSHookIvar<UILabel *>(self, "_nowPlayingArtistLabel");
UILabel *_nowPlayingAlbumLabel = MSHookIvar<UILabel *>(self, "_nowPlayingAlbumLabel");
[_nowPlayingTitleLabel setFrame:CGRectMake(0,95,[[UIScreen mainScreen] bounds].size.width,20)];
[_nowPlayingArtistLabel setFrame:CGRectMake(0,109,[[UIScreen mainScreen] bounds].size.width,20)];
[_nowPlayingAlbumLabel setFrame:CGRectMake(0,122,[[UIScreen mainScreen] bounds].size.width,20)];
}
%end
%hook TPLCDTextView
%new
-(UIFont *)font{
UIFont *font = MSHookIvar<UIFont *>(self, "_font");
return font;
}
%end
%hook SBAwayLockBar
-(id)wellImageName{
return nil;
}
- (BOOL)usesBackgroundImage {
return NO;
}
- (id)initWithFrame:(struct CGRect)frame knobColor:(int)color{
UIView *lockBar = %orig;
UIImageView *&_shadowView(MSHookIvar<UIImageView *>(self, "_shadowView"));
[_shadowView removeFromSuperview];
return lockBar;
}
- (id)initWithFrame:(struct CGRect)frame knobImage:(id)image{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(60, 47), NO, 0.0);
UIImage *blank = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIView *lockBar = %orig(frame,blank);
UIImageView *&_shadowView(MSHookIvar<UIImageView *>(self, "_shadowView"));
[_shadowView removeFromSuperview];
return lockBar;
}
%end
%hook SBDeviceLockView
- (void)notifyDelegateThatCancelButtonWasPressed{
//Slide lockscreen back to default position after cancel button is pressed in lockscreen
float width = ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height;
for(UIView *obj in [[[%c(SBAwayController) sharedAwayController] awayView] subviews]){
if(obj != [[[[%c(SBAwayController) sharedAwayController] awayView] subviews] objectAtIndex:0]){
CGPoint center = obj.center;
center.x = width/2;
[UIView animateWithDuration:0.6
animations:^{
obj.center = center;
}
completion:^(BOOL finished){
}];
}
[[[[%c(SBAwayController) sharedAwayController] awayView] bottomBar] setHidden:NO];
}
%orig;
}
%end
%hook SBAwayMediaControlsView
- (void)layoutSubviews{
%orig;
for(UIView *obj in [self subviews]){
if ([obj isMemberOfClass:NSClassFromString(@"UIView")]){ //This is the MediaContols Thin Line
[obj removeFromSuperview];
}
}
}
%end
%hook TPLCDBar
//Everything here make sure there is no thin black/grey line below the view
- (id)initWithDefaultSize{
id topBar = %orig;
UIImageView *&_shadowView(MSHookIvar<UIImageView *>(self, "_shadowView"));
[_shadowView removeFromSuperview];
return topBar;
}
- (id)initWithDefaultSizeForOrientation:(int)arg1{
id topBar = %orig;
UIImageView *&_shadowView(MSHookIvar<UIImageView *>(self, "_shadowView"));
[_shadowView removeFromSuperview];
return topBar;
}
-(id)initWithFrame:(CGRect)frame{
id topBar = %orig;
UIImageView *&_shadowView(MSHookIvar<UIImageView *>(self, "_shadowView"));
[_shadowView removeFromSuperview];
return topBar;
}
%end