This repository has been archived by the owner on Oct 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Tweak.xm
executable file
·164 lines (125 loc) · 3.79 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
#import <Foundation/Foundation.h>
#ifndef kCFCoreFoundationVersionNumber_iOS_7_0
#define kCFCoreFoundationVersionNumber_iOS_7_0 847.20
#endif
static BOOL enabled;
static UIInterfaceOrientation orient;
static BOOL first;
@interface FirstRunBRDelegate: NSObject <UIAlertViewDelegate>
@end
@implementation FirstRunBRDelegate
- (void)alertView:(UIAlertView *)alertView
didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Settings"])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=BetterRotate"]];
}
}
@end
static void AlertIfNeeded() {
if(first) {
first = NO;
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"Thanks for installing BetterRotate!"
message:@"Don't forget to check out the options in Settings."
delegate:[FirstRunBRDelegate new]
cancelButtonTitle:@"Dismiss"
otherButtonTitles:@"Settings",nil];
[alert1 show];
}
}
%group Common
%hook SBIconListView
+ (unsigned int)iconColumnsForInterfaceOrientation:(UIInterfaceOrientation)orientation {
return (enabled ? %orig(orient) : %orig);
}
+ (unsigned int)maxVisibleIconRowsInterfaceOrientation:(UIInterfaceOrientation)orientation {
return (enabled ? %orig(orient) : %orig);
}
+ (unsigned int)iconRowsForInterfaceOrientation:(UIInterfaceOrientation)orientation {
return (enabled ? %orig(orient) : %orig);
}
%end
// iOS 7+
%hook SBLockScreenManager
- (void) _finishUIUnlockFromSource:(int)source withOptions:(id)options {
%orig;
AlertIfNeeded();
}
%end
%end
%group Legacy
%hook SBFolderIconListView
+ (unsigned int)iconColumnsForInterfaceOrientation:(UIInterfaceOrientation)orientation {
return (enabled ? %orig(orient) : %orig);
}
+ (unsigned int)iconRowsForInterfaceOrientation:(UIInterfaceOrientation)orientation {
return (enabled ? %orig(orient) : %orig);
}
%end
%hook SBAppSwitcherBarView
+ (unsigned int)iconsPerPage:(int)arg1 {
return (enabled ? 7 : 6);
}
%end
// iOS 6
%hook SBAwayController
- (void) _finishUnlockWithSound:(BOOL)sound unlockSource:(int)source isAutoUnlock:(BOOL)is {
%orig;
AlertIfNeeded();
}
%end
// iOS 5
%hook SBAwayController
- (void) _unlockWithSound:(BOOL)sound isAutoUnlock:(BOOL)is unlockSource:(int)source {
%orig;
AlertIfNeeded();
}
%end
// iOS 4.3 XXX: check lower versions
%hook SBAwayController
- (void) _unlockWithSound:(BOOL)sound isAutoUnlock:(BOOL)is unlockType:(int)type {
%orig;
AlertIfNeeded();
}
%end
// -[SBIconController showInfoAlertIfNeeded] explains how to drag icons around the iPhone home screen
// it used to be shown to users when they unlocked their screen for the first time, and happened every unlock
// however, as of iOS 4.3, it got relegated to only appearing once the user installed an app or web clip
%hook SBIconController
- (void) showInfoAlertIfNeeded {
AlertIfNeeded();
}
%end
%end
%ctor {
if (NSDictionary *prefs = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"net.parrotgeek.br.ipad"]) {
enabled = [prefs[@"enabled"] boolValue];
orient = (UIInterfaceOrientation)[prefs[@"orient"] intValue];
first = NO;
} else {
first = YES;
prefs = @{
@"enabled": @YES,
@"orient": @4, // UIInterfaceOrientationLandscapeLeft
};
[[NSUserDefaults standardUserDefaults] setPersistentDomain:prefs forName:@"net.parrotgeek.br.ipad"];
enabled = YES;
orient = UIInterfaceOrientationLandscapeLeft;
}
if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_7_0) {
%init(Legacy);
}
%init(Common);
}
/*
investigate
SB*IconListView:
- (float)verticalIconPadding;
- (float)horizontalIconPadding;
- (float)horizontalBumpForColumn:(unsigned int)arg1;
- (float)sideIconInset;
both:
- (float)bottomIconInset;
- (float)topIconInset;
*/