-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTweak.xm
More file actions
108 lines (80 loc) · 3.4 KB
/
Tweak.xm
File metadata and controls
108 lines (80 loc) · 3.4 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
#import "Tweak.h"
#ifdef DEBUG
#define ALERT(...) do { \
NSString *alertString = [NSString stringWithFormat:__VA_ARGS__]; \
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Idefix2020 Debug Alert" \
message:alertString \
delegate:nil \
cancelButtonTitle:@"OK" \
otherButtonTitles:nil]; \
[alert show]; \
} while(0)
#else
#define ALERT(...)
#endif
int counter = 0;
BOOL isLandscape = NO;
CGPoint savedPositionPortrait = {-1000.0,-1000.0};
CGPoint savedPositionLandscape = {-1000.0,-1000.0};
BOOL turnDisplay = NO;
UIView *thumbnailView = nil;
%hook ZMZoomViewController
- (void)handledragThumbnailViewGesture:(UIPanGestureRecognizer*)panGestureRecognizer { // arg is a UIPanGestureRecognizer
if (thumbnailView == nil) {
thumbnailView = panGestureRecognizer.view;
}
CGPoint translatedPoint = [panGestureRecognizer translationInView:panGestureRecognizer.view.superview];
if ((panGestureRecognizer.state == UIGestureRecognizerStateCancelled) || (panGestureRecognizer.state == UIGestureRecognizerStateFailed) || (panGestureRecognizer.state == UIGestureRecognizerStateEnded) || (panGestureRecognizer.state == UIGestureRecognizerStateRecognized)) {
[%c(ZMZoomViewController) checkLandscapeOrientation];
if (isLandscape) {
savedPositionLandscape = thumbnailView.center;
}
else {
savedPositionPortrait = thumbnailView.center;
}
}
translatedPoint = CGPointMake(panGestureRecognizer.view.center.x+translatedPoint.x, panGestureRecognizer.view.center.y+translatedPoint.y);
[panGestureRecognizer.view setCenter:translatedPoint];
[panGestureRecognizer setTranslation:CGPointZero inView:panGestureRecognizer.view];
}
- (void)adjustThumbnailPositionWithAnimate:(BOOL)arg ResumeVideoStream:(BOOL)arg2{
NSLog(@"[zoomTweak] -(void)adjustThumbnailPositionWithAnimate:(BOOL)%@ ResumeVideoStream:(BOOL)%@", arg ? @"YES" : @"NO", arg ? @"YES" : @"NO");
[%c(ZMZoomViewController) checkLandscapeOrientation];
if (counter < 9) {
counter++;
%orig;
}
else if (turnDisplay) {
turnDisplay = NO;
%orig;
// Move thumbnailView to savedPosition
NSLog(@"[zoomTweak] isLandscape:%@", isLandscape ? @"YES" : @"NO");
if (isLandscape && !CGPointEqualToPoint(savedPositionLandscape, {-1000.0,-1000.0})) {
[thumbnailView setCenter:savedPositionLandscape];
}
else if (!CGPointEqualToPoint(savedPositionPortrait, {-1000.0,-1000.0})) {
[thumbnailView setCenter:savedPositionPortrait];
}
}
else if ((isLandscape && CGPointEqualToPoint(savedPositionLandscape, {-1000.0,-1000.0})) || (!isLandscape && CGPointEqualToPoint(savedPositionPortrait, {-1000.0,-1000.0}))) {
%orig;
}
}
- (void)statusBarOrientationChangedNotification:(NSNotification *)notification {
NSLog(@"[zoomTweak] Orientation Changed");
turnDisplay = YES;
%orig;
}
%new
+ (void)checkLandscapeOrientation {
if (@available(iOS 13.0, *)) {
UIWindow *firstWindow = [[[UIApplication sharedApplication] windows] firstObject];
if (firstWindow == nil) { isLandscape = NO; }
UIWindowScene *windowScene = firstWindow.windowScene;
if (windowScene == nil){ isLandscape = NO; }
isLandscape = UIInterfaceOrientationIsLandscape(windowScene.interfaceOrientation);
} else {
isLandscape = (UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication.statusBarOrientation));
}
}
%end