This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
XENSetupWindow.m
138 lines (103 loc) · 4.88 KB
/
XENSetupWindow.m
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
/*
Copyright (C) 2018 Matt Clarke
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import "XENSetupWindow.h"
#import "XENSetupInitialController.h"
#import "XENHResources.h"
#import <objc/runtime.h>
@interface SpringBoard : NSObject
@end
@interface SpringBoard (SetupEditor)
//-(void)_xenhtml_relayoutAfterSetupContentEditorDisplayed;
//-(void)_xenhtml_releaseSetupUI;
//-(void)_xenhtml_finaliseAfterSetup;
-(void)_xenhtml_relaunchSpringBoardAfterSetup;
@end
static XENHSetupWindow *shared;
@implementation XENHSetupWindow
+(instancetype)sharedInstance {
if (!shared) {
static dispatch_once_t p = 0;
dispatch_once(&p, ^{
shared = [[XENHSetupWindow alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
});
}
return shared;
}
+(void)finishSetupMode {
UIView *black = [[UIView alloc] initWithFrame:shared.bounds];
black.backgroundColor = [UIColor blackColor];
black.alpha = 1.0;
[shared insertSubview:black atIndex:0];
shared.backgroundColor = [UIColor clearColor];
shared.backgroundImageView.hidden = YES; // Obscured by pages now
[UIView animateWithDuration:0.5 animations:^{
shared.rootViewController.view.alpha = 0.0;
shared.rootViewController.view.transform = CGAffineTransformMakeScale(2.0, 2.0);
shared.bar.alpha = 0.0;
} completion:^(BOOL finished) {
if (finished) {
shared = nil;
/*[(SpringBoard*)[UIApplication sharedApplication] _xenhtml_finaliseAfterSetup];
[(SpringBoard*)[UIApplication sharedApplication] _xenhtml_releaseSetupUI];*/
[(SpringBoard*)[UIApplication sharedApplication] _xenhtml_relaunchSpringBoardAfterSetup];
}
}];
}
/*+(void)relayoutXenForSetupFinished {
[(SpringBoard*)[UIApplication sharedApplication] _xenhtml_relayoutAfterSetupContentEditorDisplayed];
}*/
// Allows it to render on LS.
- (bool)_shouldCreateContextAsSecure {
return YES;
}
- (void)layoutSubviews {
[super layoutSubviews];
self.backgroundImageView.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
}
-(id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor whiteColor];
self.windowLevel = 1081;
self.usingQuickSetup = NO;
// Background
NSString *imagePath = [NSString stringWithFormat:@"/Library/PreferenceBundles/XenHTMLPrefs.bundle/Background%@", [XENHResources imageSuffix]];
if (![[NSFileManager defaultManager] fileExistsAtPath:imagePath]) {
// Oh for crying out loud CoolStar
imagePath = [NSString stringWithFormat:@"/bootstrap/Library/PreferenceBundles/XenHTMLPrefs.bundle/Background%@", [XENHResources imageSuffix]];
}
UIImage *backgroundImage = [UIImage imageWithContentsOfFile:imagePath];
self.backgroundImageView = [[UIImageView alloc] initWithImage:backgroundImage];
self.backgroundImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
self.backgroundImageView.alpha = 0.3;
self.backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
[self addSubview:self.backgroundImageView];
// We want a navigation controller
XENHSetupInitialController *initial = [[XENHSetupInitialController alloc] init];
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:initial];
[navigation setNavigationBarHidden:YES];
self.rootViewController = navigation;
[navigation.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[navigation.navigationBar setShadowImage:[UIImage new]];
self.bar = [[objc_getClass("UIStatusBar") alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 20) showForegroundView:YES];
[(UIStatusBar*)self.bar requestStyle:0 animated:YES];
[(UIStatusBar*)self.bar setLegibilityStyle:0];
self.bar.frame = CGRectMake(0, 0, frame.size.width, self.bar.frame.size.height);
self.bar.tag = 1337;
[self addSubview:self.bar];
}
return self;
}
@end