-
Notifications
You must be signed in to change notification settings - Fork 3
/
Tweak.xm
626 lines (564 loc) · 30.6 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
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
#import "Tweak.h"
BOOL isPortrait() {
for (UIWindow *window in [[UIApplication sharedApplication] windows]) {
if (window.isKeyWindow) {
return UIDeviceOrientationIsPortrait(window.windowScene.interfaceOrientation);
}
}
return NO;
}
%group Atlas
// Hide everything from the old layout
%hook AVLayoutView
-(void)layoutSubviews {
self.hidden = YES;
// ik ik but I swear overriding the "hidden" getter/setter didn't work. Take that as you will
}
%end
// Steal the pre-existing AVScrubber and playPauseButton, so that I don't have to implement my own :p
%hook AVTransportControlsView
%property(nonatomic, retain) AVButton *anchorCenterItem;
%property(nonatomic, retain) AVButton *rewindButton;
%property(nonatomic, retain) AVButton *fastforwardButton;
%property(nonatomic, retain) AVButton *closeButton;
%property(nonatomic, retain) AVButton *pipButton;
%property(nonatomic, retain) AVButton *gravityButton;
%property(nonatomic, retain) AVButton *airplayButton;
%property(nonatomic, retain) AVButton *orientationButton;
%property(nonatomic, retain) AVButton *pipButton2;
%property(nonatomic, retain) AVButton *gravityButton2;
%property(nonatomic, retain) AVButton *airplayButton2;
%property(nonatomic, retain) AVButton *orientationButton2;
%property(nonatomic, retain) AVButton *pipButton3;
%property(nonatomic, retain) AVButton *gravityButton3;
%property(nonatomic, retain) AVButton *airplayButton3;
%property(nonatomic, retain) AVButton *orientationButton3;
%property(nonatomic, retain) UIView *darkOverlay;
%property (nonatomic, retain) UIView *numberView;
%property (nonatomic, retain) UILabel *leftNumber;
%property (nonatomic, retain) UILabel *rightNumber;
- (id)initWithFrame:(CGRect)arg1 styleSheet:(id)arg2 {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(leftGesture) name:@"leftGesture" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rightGesture) name:@"rightGesture" object:nil];
return %orig;
}
-(void)_layoutDoubleRowViews {
if (![self.scrubber isDescendantOfView:self]) {
self.darkOverlay = [[UIView alloc] init];
self.darkOverlay.translatesAutoresizingMaskIntoConstraints = NO;
self.darkOverlay.userInteractionEnabled = NO;
self.darkOverlay.backgroundColor = UIColor.blackColor;
[self addSubview:self.darkOverlay];
[self.darkOverlay atlas_anchorTop:self.superview.superview.superview.topAnchor leading:self.superview.superview.superview.leadingAnchor bottom:self.superview.superview.superview.bottomAnchor trailing:self.superview.superview.superview.trailingAnchor padding:UIEdgeInsetsZero size:CGSizeZero];
// This is just being used to anchor the other views and can be removed, now that I shoved everything into a single class
self.anchorCenterItem = [[%c(AVButton) alloc] init]; // This was the old playPause button, before I just repurposed the old one
self.anchorCenterItem.translatesAutoresizingMaskIntoConstraints = NO;
// Make the play button and subtitle button white
[self.standardPlayPauseButton.imageView setTintColor:UIColor.whiteColor];
[self.mediaSelectionButton.imageView setTintColor:UIColor.whiteColor];
// Rewind button.. pretty self explanatory
self.rewindButton = [[%c(AVButton) alloc] init];
[self.rewindButton setImage:[UIImage systemImageNamed:@"backward.fill"
withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:22
weight:UIImageSymbolWeightRegular
scale:UIImageSymbolScaleMedium]]
forState:UIControlStateNormal];
[self.rewindButton addTarget:self
action:@selector(rewindButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
[self.rewindButton.imageView setTintColor:UIColor.whiteColor];
self.rewindButton.translatesAutoresizingMaskIntoConstraints = NO;
// This is a fastforward button
// I learned that fastforward was spelled fastforward and not fastforeward while making this tweak :)
self.fastforwardButton = [[%c(AVButton) alloc] init];
[self.fastforwardButton setImage:[UIImage systemImageNamed:@"forward.fill"
withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:22
weight:UIImageSymbolWeightRegular
scale:UIImageSymbolScaleMedium]]
forState:UIControlStateNormal]; // tfw it doesn't line up perfectly by tabbing, so you have to use spaces ;c
[self.fastforwardButton addTarget:self
action:@selector(fastforwardButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
[self.fastforwardButton.imageView setTintColor:UIColor.whiteColor];
self.fastforwardButton.translatesAutoresizingMaskIntoConstraints = NO;
for (UIView *view in @[self.anchorCenterItem, self.rewindButton, self.fastforwardButton]) [self addSubview:view];
// I use self.superview.superview.superview a lot in this project, but I don't even know what it is
// It just happened to have bounds that fit the whole screen so I used it
// CODING 100
[self.anchorCenterItem atlas_centerInView:self.superview.superview.superview];
[self.anchorCenterItem atlas_heightWidthAnchorsEqualToSize:CGSizeMake(30, 30)];
// UIView extensions for constraints are pog
// making UIs without them would be such a pain
// feel free to steal my UIView+Constrinats.h/.m files
[self.rewindButton atlas_anchorTop:self.anchorCenterItem.topAnchor
leading:nil
bottom:self.anchorCenterItem.bottomAnchor
trailing:self.anchorCenterItem.leadingAnchor
padding:UIEdgeInsetsMake(0, 0, 0, 25)
size:CGSizeMake(30, 30)];
[self.fastforwardButton atlas_anchorTop:self.anchorCenterItem.topAnchor
leading:self.anchorCenterItem.trailingAnchor
bottom:self.anchorCenterItem.bottomAnchor
trailing:nil
padding:UIEdgeInsetsMake(0, 25, 0, 0)
size:CGSizeMake(30, 30)];
self.pipButton = [[%c(AVButton) alloc] init];
[self.pipButton setImage:[UIImage systemImageNamed:@"pip" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.pipButton.imageView setTintColor:UIColor.whiteColor];
[self.pipButton addTarget:self
action:@selector(pipButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
self.pipButton.translatesAutoresizingMaskIntoConstraints = NO;
self.pipButton2 = [[%c(AVButton) alloc] init];
[self.pipButton2 setImage:[UIImage systemImageNamed:@"pip" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.pipButton2.imageView setTintColor:UIColor.whiteColor];
[self.pipButton2 addTarget:self
action:@selector(pipButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
self.pipButton2.translatesAutoresizingMaskIntoConstraints = NO;
self.pipButton3 = [[%c(AVButton) alloc] init];
[self.pipButton3 setImage:[UIImage systemImageNamed:@"pip" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.pipButton3.imageView setTintColor:UIColor.whiteColor];
[self.pipButton3 addTarget:self
action:@selector(pipButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
self.pipButton3.translatesAutoresizingMaskIntoConstraints = NO;
self.gravityButton = [[%c(AVButton) alloc] init]; // person.crop.rectangle lol I ~~couldn't~~ didn't want to reuse the original image for various reasons, mainly because it wasn't a standard SFSymbol
[self.gravityButton setImage:[UIImage systemImageNamed:@"person.crop.rectangle" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.gravityButton.imageView setTintColor:UIColor.whiteColor];
[self.gravityButton addTarget:self
action:@selector(gravityButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
self.gravityButton.translatesAutoresizingMaskIntoConstraints = NO;
self.gravityButton2 = [[%c(AVButton) alloc] init]; // person.crop.rectangle lol I ~~couldn't~~ didn't want to reuse the original image for various reasons, mainly because it wasn't a standard SFSymbol
[self.gravityButton2 setImage:[UIImage systemImageNamed:@"person.crop.rectangle" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.gravityButton2.imageView setTintColor:UIColor.whiteColor];
[self.gravityButton2 addTarget:self
action:@selector(gravityButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
self.gravityButton2.translatesAutoresizingMaskIntoConstraints = NO;
self.gravityButton3 = [[%c(AVButton) alloc] init]; // person.crop.rectangle lol I ~~couldn't~~ didn't want to reuse the original image for various reasons, mainly because it wasn't a standard SFSymbol
[self.gravityButton3 setImage:[UIImage systemImageNamed:@"person.crop.rectangle" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.gravityButton3.imageView setTintColor:UIColor.whiteColor];
[self.gravityButton3 addTarget:self
action:@selector(gravityButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
self.gravityButton3.translatesAutoresizingMaskIntoConstraints = NO;
self.airplayButton = [[%c(AVButton) alloc] init];
[self.airplayButton setImage:[UIImage systemImageNamed:@"airplayvideo" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.airplayButton.imageView setTintColor:UIColor.whiteColor];
[self.airplayButton addTarget:self
action:@selector(airplayButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
self.airplayButton.translatesAutoresizingMaskIntoConstraints = NO;
self.airplayButton2 = [[%c(AVButton) alloc] init];
[self.airplayButton2 setImage:[UIImage systemImageNamed:@"airplayvideo" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.airplayButton2.imageView setTintColor:UIColor.whiteColor];
[self.airplayButton2 addTarget:self
action:@selector(airplayButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
self.airplayButton2.translatesAutoresizingMaskIntoConstraints = NO;
self.airplayButton3 = [[%c(AVButton) alloc] init];
[self.airplayButton3 setImage:[UIImage systemImageNamed:@"airplayvideo" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.airplayButton3.imageView setTintColor:UIColor.whiteColor];
[self.airplayButton3 addTarget:self
action:@selector(airplayButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
self.airplayButton3.translatesAutoresizingMaskIntoConstraints = NO;
self.orientationButton = [[%c(AVButton) alloc] init];
[self.orientationButton setImage:[UIImage systemImageNamed:@"lock.rotation" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.orientationButton setImage:[UIImage systemImageNamed:@"lock.rotation.open" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateSelected];
[self.orientationButton.imageView setTintColor:UIColor.whiteColor];
[self.orientationButton addTarget:self
action:@selector(orientationButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
self.orientationButton.translatesAutoresizingMaskIntoConstraints = NO;
self.orientationButton2 = [[%c(AVButton) alloc] init];
[self.orientationButton2 setImage:[UIImage systemImageNamed:@"lock.rotation" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.orientationButton2 setImage:[UIImage systemImageNamed:@"lock.rotation.open" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateSelected];
[self.orientationButton2.imageView setTintColor:UIColor.whiteColor];
[self.orientationButton2 addTarget:self
action:@selector(orientationButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
self.orientationButton2.translatesAutoresizingMaskIntoConstraints = NO;
self.orientationButton3 = [[%c(AVButton) alloc] init];
[self.orientationButton3 setImage:[UIImage systemImageNamed:@"lock.rotation" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.orientationButton3 setImage:[UIImage systemImageNamed:@"lock.rotation.open" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateSelected];
[self.orientationButton3.imageView setTintColor:UIColor.whiteColor];
[self.orientationButton3 addTarget:self
action:@selector(orientationButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
self.orientationButton3.translatesAutoresizingMaskIntoConstraints = NO;
self.closeButton = [[%c(AVButton) alloc] init];
[self.closeButton setImage:[UIImage systemImageNamed:@"xmark" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:20 weight:UIImageSymbolWeightRegular scale:UIImageSymbolScaleMedium]]forState:UIControlStateNormal];
[self.closeButton.imageView setTintColor:UIColor.whiteColor];
[self.closeButton addTarget:self
action:@selector(closeButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
self.closeButton.translatesAutoresizingMaskIntoConstraints = NO;
self.mediaSelectionButton.translatesAutoresizingMaskIntoConstraints = NO;
UIStackView *buttonsStack = [[UIStackView alloc] init];
buttonsStack.axis = UILayoutConstraintAxisHorizontal;
buttonsStack.distribution = UIStackViewDistributionFillEqually;
buttonsStack.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:buttonsStack];
[self addSubview:self.closeButton];
// Subtitle button
if (showSubtitlesButton) {
[buttonsStack addArrangedSubview:self.mediaSelectionButton];
}
switch (buttonOneStyle) {
case 0:
[buttonsStack addArrangedSubview:self.gravityButton];
self.gravityButton.alpha = 0;
break;
case 1:
[buttonsStack addArrangedSubview:self.gravityButton];
break;
case 2:
[buttonsStack addArrangedSubview:self.airplayButton];
break;
case 3:
[buttonsStack addArrangedSubview:self.pipButton];
break;
// case 4:
// [buttonsStack addArrangedSubview:self.orientationButton];
// break;
default:
break;
}
switch (buttonTwoStyle) {
case 0:
[buttonsStack addArrangedSubview:self.gravityButton2];
self.gravityButton2.alpha = 0;
case 1:
[buttonsStack addArrangedSubview:self.gravityButton2];
break;
case 2:
[buttonsStack addArrangedSubview:self.airplayButton2];
break;
case 3:
[buttonsStack addArrangedSubview:self.pipButton2];
break;
// case 4:
// [buttonsStack addArrangedSubview:self.mediaSelectionButton2];
// break;
// case 4:
// [buttonsStack addArrangedSubview:self.orientationButton2];
// break;
default:
break;
}
switch (buttonThreeStyle) {
case 0:
[buttonsStack addArrangedSubview:self.gravityButton3];
self.gravityButton3.alpha = 0;
case 1:
[buttonsStack addArrangedSubview:self.gravityButton3];
break;
case 2:
[buttonsStack addArrangedSubview:self.airplayButton3];
break;
case 3:
[buttonsStack addArrangedSubview:self.pipButton3];
break;
// case 4:
// [buttonsStack addArrangedSubview:self.orientationButton3];
// break;
default:
break;
}
[buttonsStack atlas_anchorTop:self.superview.superview.topAnchor leading:nil bottom:nil trailing:self.superview.superview.superview.trailingAnchor padding:UIEdgeInsetsMake(0, 0, 15, 15) size:CGSizeMake(150, 40)];
[self.closeButton atlas_anchorTop:self.superview.superview.topAnchor leading:self.superview.superview.superview.leadingAnchor bottom:nil trailing:nil padding:UIEdgeInsetsMake(0, 15, 15, 0) size:CGSizeMake(40, 40)];
[self addSubview:self.scrubber];
[self addSubview:self.elapsedTimeLabel];
[self addSubview:self.timeRemainingLabel];
[self addSubview:self.standardPlayPauseButton];
[self addSubview:self.liveBroadcastLabel];
self.standardPlayPauseButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.standardPlayPauseButton atlas_centerInView:self.superview.superview.superview];
[self.standardPlayPauseButton atlas_heightWidthAnchorsEqualToSize:CGSizeMake(30, 30)];
[self.scrubber atlas_anchorTop:nil
leading:self.leadingAnchor
bottom:self.bottomAnchor
trailing:self.trailingAnchor
padding:UIEdgeInsetsMake(0, 10, 0, 10)
size:CGSizeMake(0,40)];
[self.elapsedTimeLabel atlas_anchorTop:nil
leading:self.scrubber.leadingAnchor
bottom:self.scrubber.topAnchor
trailing:nil
padding:UIEdgeInsetsMake(0, 0, 0, 0)
size:CGSizeMake(80,20)];
[self.timeRemainingLabel atlas_anchorTop:nil
leading:nil
bottom:self.scrubber.topAnchor
trailing:self.scrubber.trailingAnchor
padding:UIEdgeInsetsMake(0, 0, 0, 0)
size:CGSizeMake(80,20)];
[self.liveBroadcastLabel atlas_anchorTop:nil
leading:self.leadingAnchor
bottom:self.bottomAnchor
trailing:self.trailingAnchor
padding:UIEdgeInsetsMake(0, 10, 0, 10)
size:CGSizeMake(0,40)];
[self.elapsedTimeLabel.label setTextAlignment:NSTextAlignmentLeft];
[self.timeRemainingLabel.label setTextAlignment:NSTextAlignmentRight];
self.numberView = [[UIView alloc] init];
self.numberView.userInteractionEnabled = NO;
self.numberView.backgroundColor = UIColor.clearColor;
[self addSubview:self.numberView];
[self.numberView atlas_anchorTop:self.superview.superview.superview.topAnchor leading:self.superview.superview.superview.leadingAnchor bottom:self.superview.superview.superview.bottomAnchor trailing:self.superview.superview.superview.trailingAnchor padding:UIEdgeInsetsZero size:CGSizeZero];
self.leftNumber = [UILabel new];
self.leftNumber.font = [UIFont boldSystemFontOfSize:20];
self.leftNumber.userInteractionEnabled = NO;
self.leftNumber.text = [NSString stringWithFormat:@"-%ld", backSeconds];
self.leftNumber.textColor = UIColor.whiteColor;
[self.leftNumber setTextAlignment:NSTextAlignmentLeft];
[self.numberView addSubview:self.leftNumber];
[self.leftNumber atlas_anchorTop:self.numberView.topAnchor leading:self.numberView.leadingAnchor bottom:self.numberView.bottomAnchor trailing:nil padding:UIEdgeInsetsMake(0,40,0,0) size:CGSizeMake(80, 0)];
self.rightNumber = [UILabel new];
self.rightNumber.font = [UIFont boldSystemFontOfSize:20];
self.rightNumber.userInteractionEnabled = NO;
self.rightNumber.text = [NSString stringWithFormat:@"+%ld", aheadSeconds];
self.rightNumber.textColor = UIColor.whiteColor;
[self.rightNumber setTextAlignment:NSTextAlignmentRight];
[self.numberView addSubview:self.rightNumber];
[self.rightNumber atlas_anchorTop:self.numberView.topAnchor leading:nil bottom:self.numberView.bottomAnchor trailing:self.numberView.trailingAnchor padding:UIEdgeInsetsMake(0,0,0,40) size:CGSizeMake(80, 0)];
// If we're livestreaming, don't show the slider controls
if (!self.showsLiveStreamingControls) {
self.scrubber.alpha = 0;
self.elapsedTimeLabel.alpha = 0;
self.timeRemainingLabel.alpha = 0;
self.liveBroadcastLabel.alpha = 1;
}
self.anchorCenterItem.alpha = 0;
self.rewindButton.alpha = 1;
self.fastforwardButton.alpha = 1;
self.closeButton.alpha = 1;
self.scrubber.alpha = 1;
self.elapsedTimeLabel.alpha = 1;
self.timeRemainingLabel.alpha = 1;
self.darkOverlay.alpha = 0.4f;
self.numberView.alpha = 1;
self.liveBroadcastLabel.alpha = 0;
self.leftNumber.alpha = 0;
self.rightNumber.alpha = 0;
}
}
-(void)_layoutSingleRowViews {
// the single row layout is what the video player looks like in landscape mode
// So, this runs when the orientation is in landscape
[self _layoutDoubleRowViews]; // This is here in case I start the video in landscape
// The lack of %orig is so that the old views don't appear
}
%new
-(void)closeButtonPressed {
[[NSNotificationCenter defaultCenter] postNotificationName:@"doneButtonFromCustomButton" object:self];
}
%new
-(void)rewindButtonPressed {
[[NSNotificationCenter defaultCenter] postNotificationName:@"skipBack" object:self];
}
%new
-(void)fastforwardButtonPressed {
[[NSNotificationCenter defaultCenter] postNotificationName:@"skipAhead" object:self];
}
%new
-(void)pipButtonPressed {
[[NSNotificationCenter defaultCenter] postNotificationName:@"pipButton" object:self];
}
%new
-(void)gravityButtonPressed {
[[NSNotificationCenter defaultCenter] postNotificationName:@"videoGravityButton" object:self];
}
%new
-(void)airplayButtonPressed {
[[NSNotificationCenter defaultCenter] postNotificationName:@"airplayButton" object:self];
}
// %new
// -(void)mediaSelectionButtonPressThing {
// [self mediaSelectionButtonTapped:self];
// }
// %new
// -(void)orientationButtonPressed:(UIButton *)sender {
// sender.selected = !sender.selected;
// lockOrientation();
// NSLog(@"hi");
// }
%new
-(void)leftGesture {
if (isPortrait()) {
self.leftNumber.font = [UIFont boldSystemFontOfSize:20];
} else {
self.leftNumber.font = [UIFont boldSystemFontOfSize:30];
}
CGRect frame = self.leftNumber.frame;
[UIView animateWithDuration:0.3
delay:0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
self.leftNumber.alpha = 1;
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
self.leftNumber.frame = CGRectMake(frame.origin.x + 15, frame.origin.y, frame.size.width, frame.size.height);
} else {
self.leftNumber.frame = CGRectMake(frame.origin.x + 8, frame.origin.y, frame.size.width, frame.size.height);
}
}
completion:^(BOOL finished){
[UIView animateWithDuration:0.2
animations:^{
self.leftNumber.alpha = 0;
}
completion:^(BOOL finished){
self.leftNumber.frame = frame;
}];
}];
}
%new
-(void)rightGesture {
if (isPortrait()) {
self.rightNumber.font = [UIFont boldSystemFontOfSize:20];
} else {
self.rightNumber.font = [UIFont boldSystemFontOfSize:30];
}
CGRect frame = self.rightNumber.frame;
[UIView animateWithDuration:0.3
delay:0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
self.rightNumber.alpha = 1;
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
self.rightNumber.frame = CGRectMake(frame.origin.x - 15, frame.origin.y, frame.size.width, frame.size.height);
} else {
self.rightNumber.frame = CGRectMake(frame.origin.x - 8, frame.origin.y, frame.size.width, frame.size.height);
} }
completion:^(BOOL finished){
[UIView animateWithDuration:0.2
animations:^{
self.rightNumber.alpha = 0;
}
completion:^(BOOL finished){
self.rightNumber.frame = frame;
}];
}];
}
-(void)dealloc {
%orig;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
%end
%hook AVLabel
-(UILabel *)label {
UILabel *whiteLabel = %orig;
whiteLabel.textColor = [UIColor colorWithRed:1.00 green:1.00 blue:1.00 alpha:1.00];
return whiteLabel;
}
%end
%hook AVRoutePickerView
-(id)initWithFrame:(CGRect)arg1 {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_routePickerButtonTapped:) name:@"airplayButton" object:nil];
return %orig;
}
// This is called when we press the screen mirroring button
-(void)_routePickerButtonTapped:(id)arg1 {
%orig;
}
%end
%hook AVPlayerViewController
-(id)initWithPlayerLayerView:(id)arg1 {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doneButtonTapped:) name:@"doneButtonFromCustomButton" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleSkipAhead) name:@"skipAhead" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleSkipBack) name:@"skipBack" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pictureInPictureButtonTapped:) name:@"pipButton" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoGravityButtonTapped:) name:@"videoGravityButton" object:nil];
return %orig;
}
-(void)doneButtonTapped:(id)arg1 {
%orig;
}
-(void)_handleSkipBack15SecondsKeyCommand:(id)arg1 {
%orig;
}
-(void)_handleSkipAhead15SecondsKeyCommand:(id)arg1 {
%orig;
}
%new
-(void)_handleSkipAhead {
AVPlayerController *playerController = [self playerController];
// requiresLinearPlayback is YES for unskippable videos
if (self.requiresLinearPlayback == NO) {
if ([playerController respondsToSelector:@selector(seekByTimeInterval:toleranceBefore:toleranceAfter:)]) {
[playerController seekByTimeInterval:aheadSeconds toleranceBefore:0.5 toleranceAfter:0.5];
} else {
double currentTime = [playerController currentTime];
[playerController seekToTime:currentTime + aheadSeconds];
}
}
}
%new
-(void)_handleSkipBack {
AVPlayerController *playerController = [self playerController];
// requiresLinearPlayback is YES for unskippable videos
if (self.requiresLinearPlayback == NO) {
if ([playerController respondsToSelector:@selector(seekByTimeInterval:toleranceBefore:toleranceAfter:)]) {
[playerController seekByTimeInterval:-(backSeconds) toleranceBefore:0.5 toleranceAfter:0.5];
} else {
double currentTime = [playerController currentTime];
[playerController seekToTime:currentTime - backSeconds];
}
}
}
-(void)pictureInPictureButtonTapped:(id)arg1 {
// NSLog(@"pictureInPictureButtonTapped");
%orig;
}
-(void)videoGravityButtonTapped:(id)arg1 {
// NSLog(@"videoGravityButtonTapped");
%orig;
}
// I don't think I need this here :)
-(void)_handleSingleTapGesture:(id)arg1 {
%orig;
}
-(void)_handleDoubleTapGesture:(UITapGestureRecognizer *)arg1 {
if (!gestureEnabled) return;
// This handles the rewind/fastforward double tap gesture
// It just checks which side of the screen the touch point came from
if (arg1.state == UIGestureRecognizerStateEnded) {
// CGPoint point = [arg1 locationInView:self.view.superview.superview.superview]; // This works
// CGPoint point = [arg1 locationInView:self.view.superview]; // This works in the appleTV app
CGPoint point = [arg1 locationInView:self.view]; // Ig this works everywhere
CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
if (point.x < (screenWidth/2)) {
// Left
[self _handleSkipBack];
// Show the -15
if (animEnabled) [[NSNotificationCenter defaultCenter] postNotificationName:@"leftGesture" object:self];
} else {
// Right
[self _handleSkipAhead];
// Show the +15
if (animEnabled) [[NSNotificationCenter defaultCenter] postNotificationName:@"rightGesture" object:self];
}
}
}
-(void)dealloc {
%orig;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
%end
%end
%ctor {
preferences = [[HBPreferences alloc] initWithIdentifier:@"com.chr1s.atlasprefs"];
[preferences registerBool:&enabled default:YES forKey:@"enabled"];
[preferences registerBool:&gestureEnabled default:YES forKey:@"gestureEnabled"];
[preferences registerBool:&animEnabled default:YES forKey:@"animEnabled"];
[preferences registerBool:&showSubtitlesButton default:YES forKey:@"showSubtitlesButton"];
[preferences registerInteger:&buttonOneStyle default:2 forKey:@"buttonOne"];
[preferences registerInteger:&buttonTwoStyle default:1 forKey:@"buttonTwo"];
[preferences registerInteger:&buttonThreeStyle default:3 forKey:@"buttonThree"];
[preferences registerInteger:&aheadSeconds default:15 forKey:@"skipAhead"];
[preferences registerInteger:&backSeconds default:15 forKey:@"skipBack"];
if (enabled && ![NSBundle.mainBundle.bundleIdentifier isEqualToString:@"com.tigisoftware.Filza"]) %init(Atlas);
}