├── SettingsButtons.plist
├── settingsbuttonsprefs
├── Resources
│ ├── icon.png
│ ├── banner.png
│ ├── banner2.png
│ ├── icon@2x.png
│ ├── icon@3x.png
│ ├── Info.plist
│ └── Root.plist
├── entry.plist
├── Makefile
├── SETBTNSPreferences.h
└── SETBTNSPreferences.m
├── packages
└── com.nahtedetihw.settingsbuttons_1.6_iphoneos-arm.deb
├── layout
└── Library
│ └── Application Support
│ └── SettingsButtons
│ ├── darkmode@2x.png
│ ├── darkmode@3x.png
│ ├── ldrestart@2x.png
│ ├── ldrestart@3x.png
│ ├── lightmode@2x.png
│ ├── lightmode@3x.png
│ ├── lowpower@2x.png
│ ├── lowpower@3x.png
│ ├── respring@2x.png
│ ├── respring@3x.png
│ ├── safemode@2x.png
│ ├── safemode@3x.png
│ ├── flashlight@2x.png
│ └── flashlight@3x.png
├── control
├── Makefile
├── README.md
├── NSTask.h
└── Tweak.xm
/SettingsButtons.plist:
--------------------------------------------------------------------------------
1 | {
2 | Filter = {
3 | Bundles = (
4 | "com.apple.Preferences",
5 | );
6 | };
7 | }
--------------------------------------------------------------------------------
/settingsbuttonsprefs/Resources/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/settingsbuttonsprefs/Resources/icon.png
--------------------------------------------------------------------------------
/settingsbuttonsprefs/Resources/banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/settingsbuttonsprefs/Resources/banner.png
--------------------------------------------------------------------------------
/settingsbuttonsprefs/Resources/banner2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/settingsbuttonsprefs/Resources/banner2.png
--------------------------------------------------------------------------------
/settingsbuttonsprefs/Resources/icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/settingsbuttonsprefs/Resources/icon@2x.png
--------------------------------------------------------------------------------
/settingsbuttonsprefs/Resources/icon@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/settingsbuttonsprefs/Resources/icon@3x.png
--------------------------------------------------------------------------------
/packages/com.nahtedetihw.settingsbuttons_1.6_iphoneos-arm.deb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/packages/com.nahtedetihw.settingsbuttons_1.6_iphoneos-arm.deb
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/darkmode@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/darkmode@2x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/darkmode@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/darkmode@3x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/ldrestart@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/ldrestart@2x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/ldrestart@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/ldrestart@3x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/lightmode@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/lightmode@2x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/lightmode@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/lightmode@3x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/lowpower@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/lowpower@2x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/lowpower@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/lowpower@3x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/respring@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/respring@2x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/respring@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/respring@3x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/safemode@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/safemode@2x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/safemode@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/safemode@3x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/flashlight@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/flashlight@2x.png
--------------------------------------------------------------------------------
/layout/Library/Application Support/SettingsButtons/flashlight@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nahtedetihw/SettingsButtons/HEAD/layout/Library/Application Support/SettingsButtons/flashlight@3x.png
--------------------------------------------------------------------------------
/control:
--------------------------------------------------------------------------------
1 | Package: com.nahtedetihw.settingsbuttons
2 | Name: SettingsButtons
3 | Version: 1.6
4 | Architecture: iphoneos-arm
5 | Description: Buttons for Settings NavBar!
6 | Maintainer: Ethan Whited
7 | Author: Ethan Whited
8 | Section: Tweaks
9 | Depends: mobilesubstrate, ws.hbang.common, com.spark.libsparkcolourpicker, com.smokin1337.ldrestarthelper
10 |
--------------------------------------------------------------------------------
/settingsbuttonsprefs/entry.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | entry
6 |
7 | bundle
8 | settingsbuttonsprefs
9 | cell
10 | PSLinkCell
11 | detail
12 | SETBTNSPreferencesListController
13 | icon
14 | icon.png
15 | isController
16 |
17 | label
18 | SettingsButtons
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | TARGET := iphone:clang:latest:13.0
2 | INSTALL_TARGET_PROCESSES = Preferences
3 |
4 | ARCHS = arm64 arm64e
5 |
6 | DEBUG = 0
7 | FINALPACKAGE = 1
8 |
9 | PREFIX=$(THEOS)/toolchain/Xcode.xctoolchain/usr/bin/
10 |
11 | SYSROOT=$(THEOS)/sdks/iphoneos14.0.sdk
12 |
13 | include $(THEOS)/makefiles/common.mk
14 |
15 | TWEAK_NAME = SettingsButtons
16 |
17 | SettingsButtons_FILES = Tweak.xm
18 | SettingsButtons_CFLAGS = -fobjc-arc -Wno-deprecated-declarations
19 | SettingsButtons_FRAMEWORKS = UIKit
20 | SettingsButtons_EXTRA_FRAMEWORKS += Cephei
21 | SettingsButtons_LIBRARIES += sparkcolourpicker
22 |
23 | SUBPROJECTS += settingsbuttonsprefs
24 |
25 | include $(THEOS_MAKE_PATH)/tweak.mk
26 |
27 | after-install::
28 | install.exec "killall -9 Preferences && killall -9 SpringBoard"
29 | include $(THEOS_MAKE_PATH)/aggregate.mk
--------------------------------------------------------------------------------
/settingsbuttonsprefs/Makefile:
--------------------------------------------------------------------------------
1 | ARCHS = arm64 arm64e
2 |
3 | include $(THEOS)/makefiles/common.mk
4 |
5 | PREFIX=$(THEOS)/toolchain/Xcode.xctoolchain/usr/bin/
6 |
7 | SYSROOT=$(THEOS)/sdks/iphoneos14.0.sdk
8 |
9 | BUNDLE_NAME = settingsbuttonsprefs
10 | settingsbuttonsprefs_FILES = SETBTNSPreferences.m
11 | settingsbuttonsprefs_INSTALL_PATH = /Library/PreferenceBundles
12 | settingsbuttonsprefs_FRAMEWORKS = UIKit
13 | settingsbuttonsprefs_PRIVATE_FRAMEWORKS = Preferences
14 | settingsbuttonsprefs_EXTRA_FRAMEWORKS = Cephei CepheiPrefs
15 | settingsbuttonsprefs_LIBRARIES += sparkcolourpicker
16 |
17 | include $(THEOS_MAKE_PATH)/bundle.mk
18 |
19 | internal-stage::
20 | $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END)
21 | $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/settingsbuttonsprefs.plist$(ECHO_END)
22 |
--------------------------------------------------------------------------------
/settingsbuttonsprefs/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | settingsbuttonsprefs
9 | CFBundleIdentifier
10 | com.nahtedetihw.settingsbuttonsprefs
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1.0
21 | NSPrincipalClass
22 | SETBTNSPreferencesListController
23 |
24 |
25 |
--------------------------------------------------------------------------------
/settingsbuttonsprefs/SETBTNSPreferences.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import
4 | #import
5 | #import
6 | #import
7 | #import "SparkAppListTableViewController.h"
8 |
9 | @interface SETBTNSPreferencesListController : HBRootListController {
10 |
11 | UITableView * _table;
12 |
13 | }
14 |
15 | @property (nonatomic, retain) UIBarButtonItem *killButton;
16 | @property (nonatomic, retain) UIView *headerView;
17 | @property (nonatomic, retain) UIImageView *headerImageView;
18 | @property (nonatomic, retain) UILabel *titleLabel;
19 | @property (nonatomic, retain) UIImageView *iconView;
20 | @property (nonatomic, retain) NSArray *versionArray;
21 | - (void)handleYesGesture:(UIButton *)sender;
22 | - (void)handleNoGesture:(UIButton *)sender;
23 | @end
24 |
25 | @interface SETBTNSAppearanceSettings: HBAppearanceSettings
26 | @end
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |
4 | # SettingsButtons
5 |
6 | ## Add useful buttons to the Navigation Bar in Settings App
7 |
8 | ### SettingsButtons is compatible with iOS 13 and iOS 14.
9 |
10 | ** SettingsButtons gives a useful way of toggling dark mode, safe mode, or respring straight from settings, with a very clean look **
11 |
12 | ### Custom themes
13 |
14 | All of the icons are in `/Library/Application Support/SettingsButtons`
15 |
16 | Themers can place their icons in `CustomTheme.theme/Folders/SettingsButtons`
17 |
18 | `darkmode@2x.png` - 60x60
19 | `darkmode@3x.png` - 90x90
20 | `lightmode@2x.png` - 60x60
21 | `lightmode@3x.png` - 90x90
22 | `flashlight@2x.png` - 60x60
23 | `flashlight@3x.png` - 90x90
24 | `ldrestart@2x.png` - 60x60
25 | `ldrestart@3x.png` - 90x90
26 | `lowpower@2x.png` - 60x60
27 | `lowpower@3x.png` - 90x90
28 | `respring@2x.png` - 60x60
29 | `respring@3x.png` - 90x90
30 | `safemode@2x.png` - 60x60
31 | `safemode@3x.png` - 90x90
32 |
33 | * Join my Discord today to report any issues: https://discord.gg/64kVRNzKnF
34 |
35 | ### Source Code
36 | https://github.com/nahtedetihw/SettingsButtons
37 |
38 | ### Follow
39 |
40 | * [**ETHN**](https://twitter.com/ethanwhited) - follow me for more up to date info, or ask me anything.
41 |
42 | * [**Email**](mailto:ethanwhited2208@gmail.com) - open to any questions or concerns.
43 |
44 | * [**Repo**](https://repo.twickd.com) - Repo containing SettingsButtons
45 |
--------------------------------------------------------------------------------
/NSTask.h:
--------------------------------------------------------------------------------
1 | @interface NSTask : NSObject
2 | @property (copy) NSURL *executableURL;
3 | @property (copy) NSArray *arguments;
4 | @property (copy) NSDictionary *environment;
5 | @property (copy) NSURL *currentDirectoryURL;
6 | @property (retain) id standardInput;
7 | @property (retain) id standardOutput;
8 | @property (retain) id standardError;
9 | @property (readonly) int processIdentifier;
10 | @property (getter=isRunning, readonly) BOOL running;
11 | @property (readonly) int terminationStatus;
12 | @property (readonly) long long terminationReason;
13 | @property (copy) id terminationHandler;
14 | @property (assign) long long qualityOfService;
15 | + (id)allocWithZone:(NSZone*)arg1 ;
16 | + (id)currentTaskDictionary;
17 | + (id)launchedTaskWithDictionary:(id)arg1 ;
18 | + (id)launchedTaskWithLaunchPath:(id)arg1 arguments:(id)arg2 ;
19 | + (id)launchedTaskWithExecutableURL:(id)arg1 arguments:(id)arg2 error:(out id*)arg3 terminationHandler:(/*^block*/id)arg4 ;
20 | - (id)init;
21 | - (BOOL)resume;
22 | - (int)processIdentifier;
23 | - (NSURL *)executableURL;
24 | - (NSArray *)arguments;
25 | - (id)currentDirectoryPath;
26 | - (long long)qualityOfService;
27 | - (void)setQualityOfService:(long long)arg1 ;
28 | - (NSDictionary *)environment;
29 | - (void)setArguments:(NSArray *)arg1 ;
30 | - (void)setCurrentDirectoryPath:(id)arg1 ;
31 | - (id)launchPath;
32 | - (void)setLaunchPath:(id)arg1 ;
33 | - (void)setTerminationHandler:(id)arg1 ;
34 | - (id)terminationHandler;
35 | - (int)terminationStatus;
36 | - (long long)terminationReason;
37 | - (BOOL)isRunning;
38 | - (void)launch;
39 | - (BOOL)launchAndReturnError:(id*)arg1 ;
40 | - (void)setCurrentDirectoryURL:(NSURL *)arg1 ;
41 | - (NSURL *)currentDirectoryURL;
42 | - (void)setEnvironment:(NSDictionary *)arg1 ;
43 | - (void)setExecutableURL:(NSURL *)arg1 ;
44 | - (void)interrupt;
45 | - (void)terminate;
46 | - (BOOL)suspend;
47 | - (long long)suspendCount;
48 | - (void)setStandardInput:(id)arg1 ;
49 | - (void)setStandardOutput:(id)arg1 ;
50 | - (void)setStandardError:(id)arg1 ;
51 | - (id)standardInput;
52 | - (id)standardOutput;
53 | - (id)standardError;
54 | - (void)setSpawnedProcessDisclaimed:(BOOL)arg1 ;
55 | - (BOOL)isSpawnedProcessDisclaimed;
56 | @end
57 |
--------------------------------------------------------------------------------
/settingsbuttonsprefs/Resources/Root.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | items
6 |
7 |
8 | cell
9 | PSSwitchCell
10 | default
11 |
12 | defaults
13 | com.nahtedetihw.settingsbuttonsprefs
14 | key
15 | enable
16 | label
17 | Enable
18 |
19 |
20 | cell
21 | PSGroupCell
22 | label
23 | Right Side Buttons
24 |
25 |
26 | cell
27 | PSLinkListCell
28 | default
29 | 0
30 | defaults
31 | com.nahtedetihw.settingsbuttonsprefs
32 | detail
33 | PSListItemsController
34 | key
35 | rightButtonStyle
36 | label
37 | Right Button Style
38 | validValues
39 |
40 | 0
41 | 1
42 | 2
43 | 3
44 | 4
45 |
46 | validTitles
47 |
48 | Respring, SafeMode, DarkMode
49 | Respring, SafeMode, ldrestart
50 | Respring, ldrestart, DarkMode
51 | Respring, FlashLight, DarkMode
52 | Respring, FlashLight, SafeMode
53 |
54 | PostNotification
55 | com.nahtedetihw.settingsbuttonsprefs/ReloadPrefs
56 |
57 |
58 | cell
59 | PSGroupCell
60 | label
61 | Left Side Buttons
62 |
63 |
64 | cell
65 | PSSwitchCell
66 | default
67 |
68 | defaults
69 | com.nahtedetihw.settingsbuttonsprefs
70 | key
71 | enableLeftButtons
72 | label
73 | Enable Left Side Buttons
74 |
75 |
76 | cell
77 | PSLinkListCell
78 | default
79 | 0
80 | defaults
81 | com.nahtedetihw.settingsbuttonsprefs
82 | detail
83 | PSListItemsController
84 | key
85 | leftButtonStyle
86 | label
87 | Left Button Style
88 | validValues
89 |
90 | 0
91 | 1
92 | 2
93 | 3
94 | 4
95 |
96 | validTitles
97 |
98 | LowPower, ldrestart, FlashLight
99 | DarkMode, LowPower, FlashLight
100 | SafeMode, Low Power, FlashLight
101 | SafeMode, LowPower, ldrestart
102 | DarkMode, LowPower, ldrestart
103 |
104 | PostNotification
105 | com.nahtedetihw.settingsbuttonsprefs/ReloadPrefs
106 |
107 |
108 | cell
109 | PSGroupCell
110 | label
111 | Color
112 |
113 |
114 | cell
115 | PSSegmentCell
116 | default
117 | 3
118 | defaults
119 | com.nahtedetihw.settingsbuttonsprefs
120 | key
121 | colorStyle
122 | validValues
123 |
124 | 0
125 | 1
126 |
127 | validTitles
128 |
129 | Default
130 | Custom
131 |
132 | alignment
133 | 1
134 | PostNotification
135 | com.nahtedetihw.settingsbuttonsprefs/ReloadPrefs
136 |
137 |
138 | cell
139 | PSGroupCell
140 | label
141 | Dark Mode Color
142 |
143 |
144 | cell
145 | PSLinkCell
146 | cellClass
147 | SparkColourPickerCell
148 | libsparkcolourpicker
149 |
150 | defaults
151 | com.nahtedetihw.settingsbuttonsprefs.color
152 | fallback
153 | #FFFFFF
154 | alpha
155 |
156 |
157 | label
158 | Tint Color
159 | key
160 | tintColorDark
161 | PostNotification
162 | com.nahtedetihw.settingsbuttonsprefs.color/changed
163 |
164 |
165 | cell
166 | PSLinkCell
167 | cellClass
168 | SparkColourPickerCell
169 | libsparkcolourpicker
170 |
171 | defaults
172 | com.nahtedetihw.settingsbuttonsprefs.color
173 | fallback
174 | #000000
175 | alpha
176 |
177 |
178 | label
179 | Background Color
180 | key
181 | backgroundColorDark
182 | PostNotification
183 | com.nahtedetihw.settingsbuttonsprefs.color/changed
184 |
185 |
186 | cell
187 | PSGroupCell
188 | label
189 | Light Mode Color
190 |
191 |
192 | cell
193 | PSLinkCell
194 | cellClass
195 | SparkColourPickerCell
196 | libsparkcolourpicker
197 |
198 | defaults
199 | com.nahtedetihw.settingsbuttonsprefs.color
200 | fallback
201 | #000000
202 | alpha
203 |
204 |
205 | label
206 | Tint Color
207 | key
208 | tintColorLight
209 | PostNotification
210 | com.nahtedetihw.settingsbuttonsprefs.color/changed
211 |
212 |
213 | cell
214 | PSLinkCell
215 | cellClass
216 | SparkColourPickerCell
217 | libsparkcolourpicker
218 |
219 | defaults
220 | com.nahtedetihw.settingsbuttonsprefs.color
221 | fallback
222 | #FFFFFF
223 | alpha
224 |
225 |
226 | label
227 | Background Color
228 | key
229 | backgroundColorLight
230 | PostNotification
231 | com.nahtedetihw.settingsbuttonsprefs.color/changed
232 |
233 |
234 | cell
235 | PSGroupCell
236 | label
237 | Contact
238 |
239 |
240 | cellClass
241 | HBTwitterCell
242 | label
243 | ETHN
244 | user
245 | EthanWhited
246 |
247 |
248 | cell
249 | PSGroupCell
250 | footerAlignment
251 | 1
252 | footerText
253 | SettingsButtons
254 |
255 |
256 | cell
257 | PSGroupCell
258 | footerAlignment
259 | 1
260 | footerText
261 | 2021 © nahtedetihw
262 |
263 |
264 | title
265 |
266 |
267 |
268 |
--------------------------------------------------------------------------------
/settingsbuttonsprefs/SETBTNSPreferences.m:
--------------------------------------------------------------------------------
1 | #include "SETBTNSPreferences.h"
2 | #import
3 |
4 | UIImageView *secondaryHeaderImage;
5 | UIBarButtonItem *respringButtonItem;
6 | UIViewController *popController;
7 |
8 | @implementation SETBTNSPreferencesListController
9 | @synthesize killButton;
10 | @synthesize versionArray;
11 |
12 | - (NSArray *)specifiers {
13 | if (!_specifiers) {
14 | _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
15 | }
16 |
17 | return _specifiers;
18 | }
19 |
20 |
21 | - (instancetype)init {
22 |
23 | self = [super init];
24 |
25 | if (self) {
26 |
27 | UIColor *buttonBackgroundColor = [UIColor colorWithDynamicProvider:^UIColor *(UITraitCollection *traitCollection) {
28 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
29 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
30 | }
31 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
32 | return [UIColor colorWithRed:186/255.0f green:204/255.0f blue:211/255.0f alpha:1.0f];
33 | }
34 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleUnspecified) {
35 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
36 | }
37 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
38 | }];
39 |
40 | SETBTNSAppearanceSettings *appearanceSettings = [[SETBTNSAppearanceSettings alloc] init];
41 | self.hb_appearanceSettings = appearanceSettings;
42 |
43 | UIButton *respringButton = [UIButton buttonWithType:UIButtonTypeCustom];
44 | respringButton.frame = CGRectMake(0,0,30,30);
45 | respringButton.layer.cornerRadius = respringButton.frame.size.height / 2;
46 | respringButton.layer.masksToBounds = YES;
47 | respringButton.backgroundColor = buttonBackgroundColor;
48 | [respringButton setImage:[UIImage systemImageNamed:@"checkmark.circle"] forState:UIControlStateNormal];
49 | [respringButton addTarget:self action:@selector(apply:) forControlEvents:UIControlEventTouchUpInside];
50 | respringButton.tintColor = [UIColor whiteColor];
51 |
52 | respringButtonItem = [[UIBarButtonItem alloc] initWithCustomView:respringButton];
53 |
54 | self.navigationItem.rightBarButtonItem = respringButtonItem;
55 | self.navigationItem.titleView = [UIView new];
56 | self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
57 | self.titleLabel.font = [UIFont boldSystemFontOfSize:18];
58 | self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
59 | self.titleLabel.text = @"";
60 | self.titleLabel.textColor = [UIColor systemRedColor];
61 | self.titleLabel.textAlignment = NSTextAlignmentCenter;
62 | [self.navigationItem.titleView addSubview:self.titleLabel];
63 |
64 | self.iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
65 | self.iconView.contentMode = UIViewContentModeScaleAspectFit;
66 | self.iconView.image = [UIImage imageWithContentsOfFile:@"/Library/PreferenceBundles/settingsbuttonsprefs.bundle/icon.png"];
67 | self.iconView.translatesAutoresizingMaskIntoConstraints = NO;
68 | self.iconView.alpha = 0.0;
69 | [self.navigationItem.titleView addSubview:self.iconView];
70 |
71 | [NSLayoutConstraint activateConstraints:@[
72 | [self.titleLabel.topAnchor constraintEqualToAnchor:self.navigationItem.titleView.topAnchor],
73 | [self.titleLabel.leadingAnchor constraintEqualToAnchor:self.navigationItem.titleView.leadingAnchor],
74 | [self.titleLabel.trailingAnchor constraintEqualToAnchor:self.navigationItem.titleView.trailingAnchor],
75 | [self.titleLabel.bottomAnchor constraintEqualToAnchor:self.navigationItem.titleView.bottomAnchor],
76 | [self.iconView.topAnchor constraintEqualToAnchor:self.navigationItem.titleView.topAnchor],
77 | [self.iconView.leadingAnchor constraintEqualToAnchor:self.navigationItem.titleView.leadingAnchor],
78 | [self.iconView.trailingAnchor constraintEqualToAnchor:self.navigationItem.titleView.trailingAnchor],
79 | [self.iconView.bottomAnchor constraintEqualToAnchor:self.navigationItem.titleView.bottomAnchor],
80 | ]];
81 |
82 | }
83 |
84 | return self;
85 |
86 | }
87 |
88 | - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
89 |
90 | return UIModalPresentationNone;
91 | }
92 |
93 | - (void)viewWillAppear:(BOOL)animated {
94 |
95 | [super viewWillAppear:animated];
96 |
97 | CGRect frame = self.table.bounds;
98 | frame.origin.y = -frame.size.height;
99 |
100 | UIColor *navbarTintColor = [UIColor colorWithDynamicProvider:^UIColor *(UITraitCollection *traitCollection) {
101 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
102 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
103 | }
104 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
105 | return [UIColor colorWithRed:186/255.0f green:204/255.0f blue:211/255.0f alpha:1.0f];
106 | }
107 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleUnspecified) {
108 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
109 | }
110 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
111 | }];
112 |
113 | self.navigationController.navigationController.navigationBar.barTintColor = navbarTintColor;
114 | [self.navigationController.navigationController.navigationBar setShadowImage: [UIImage new]];
115 | self.navigationController.navigationController.navigationBar.tintColor = [UIColor whiteColor];
116 | self.navigationController.navigationController.navigationBar.translucent = NO;
117 |
118 | }
119 |
120 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
121 | tableView.tableHeaderView = self.headerView;
122 | return [super tableView:tableView cellForRowAtIndexPath:indexPath];
123 | }
124 |
125 | - (void)viewDidLoad {
126 |
127 | [super viewDidLoad];
128 |
129 | self.headerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
130 | self.headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,200,200)];
131 | self.headerImageView.contentMode = UIViewContentModeScaleAspectFill;
132 | self.headerImageView.image = [UIImage imageWithContentsOfFile:@"/Library/PreferenceBundles/settingsbuttonsprefs.bundle/banner.png"];
133 | self.headerImageView.translatesAutoresizingMaskIntoConstraints = NO;
134 | self.headerImageView.alpha = 1;
135 |
136 | [self.headerView addSubview:self.headerImageView];
137 | [NSLayoutConstraint activateConstraints:@[
138 | [self.headerImageView.topAnchor constraintEqualToAnchor:self.headerView.topAnchor],
139 | [self.headerImageView.leadingAnchor constraintEqualToAnchor:self.headerView.leadingAnchor],
140 | [self.headerImageView.trailingAnchor constraintEqualToAnchor:self.headerView.trailingAnchor],
141 | [self.headerImageView.bottomAnchor constraintEqualToAnchor:self.headerView.bottomAnchor],
142 | ]];
143 |
144 | _table.tableHeaderView = self.headerView;
145 |
146 | secondaryHeaderImage = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,200,200)];
147 | secondaryHeaderImage.contentMode = UIViewContentModeScaleAspectFill;
148 | secondaryHeaderImage.image = [UIImage imageWithContentsOfFile:@"/Library/PreferenceBundles/settingsbuttonsprefs.bundle/banner2.png"];
149 | secondaryHeaderImage.translatesAutoresizingMaskIntoConstraints = NO;
150 | secondaryHeaderImage.alpha = 0.0;
151 | [self.headerView addSubview:secondaryHeaderImage];
152 |
153 | [NSLayoutConstraint activateConstraints:@[
154 | [secondaryHeaderImage.topAnchor constraintEqualToAnchor:self.headerView.topAnchor],
155 | [secondaryHeaderImage.leadingAnchor constraintEqualToAnchor:self.headerView.leadingAnchor],
156 | [secondaryHeaderImage.trailingAnchor constraintEqualToAnchor:self.headerView.trailingAnchor],
157 | [secondaryHeaderImage.bottomAnchor constraintEqualToAnchor:self.headerView.bottomAnchor],
158 | ]];
159 |
160 | [UIView animateWithDuration:1.0 delay:0 options: UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat animations:^{
161 | secondaryHeaderImage.alpha = 1.0;
162 | self.headerImageView.alpha = 0;
163 | } completion:nil];
164 |
165 | }
166 |
167 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
168 | CGFloat offsetY = scrollView.contentOffset.y;
169 |
170 | if (offsetY > 200) {
171 | [UIView animateWithDuration:0.2 animations:^{
172 | self.iconView.alpha = 1.0;
173 | self.titleLabel.alpha = 0.0;
174 | }];
175 | } else {
176 | [UIView animateWithDuration:0.2 animations:^{
177 | self.iconView.alpha = 0.0;
178 | self.titleLabel.alpha = 1.0;
179 | }];
180 | }
181 |
182 | if (offsetY > 0) offsetY = 0;
183 | self.headerImageView.frame = CGRectMake(0, offsetY, self.headerView.frame.size.width, 200 - offsetY);
184 | }
185 |
186 | - (void)viewWillDisappear:(BOOL)animated {
187 | [super viewWillDisappear:animated];
188 |
189 | [self.navigationController.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor]}];
190 |
191 | }
192 |
193 | - (void)apply:(UIButton *)sender {
194 |
195 | popController = [[UIViewController alloc] init];
196 | popController.modalPresentationStyle = UIModalPresentationPopover;
197 | popController.preferredContentSize = CGSizeMake(200,130);
198 | UILabel *respringLabel = [[UILabel alloc] init];
199 | respringLabel.frame = CGRectMake(20, 20, 160, 60);
200 | respringLabel.numberOfLines = 2;
201 | respringLabel.textAlignment = NSTextAlignmentCenter;
202 | respringLabel.adjustsFontSizeToFitWidth = YES;
203 | respringLabel.font = [UIFont boldSystemFontOfSize:20];
204 | respringLabel.textColor = [UIColor labelColor];
205 | respringLabel.text = @"Kill Settings to Apply?";
206 | [popController.view addSubview:respringLabel];
207 |
208 | UIButton *yesButton = [UIButton buttonWithType:UIButtonTypeCustom];
209 | [yesButton addTarget:self
210 | action:@selector(handleYesGesture:)
211 | forControlEvents:UIControlEventTouchUpInside];
212 | [yesButton setTitle:@"Yes" forState:UIControlStateNormal];
213 | [yesButton setTitleColor:[UIColor labelColor] forState:UIControlStateNormal];
214 | yesButton.frame = CGRectMake(100, 100, 100, 30);
215 | [popController.view addSubview:yesButton];
216 |
217 | UIButton *noButton = [UIButton buttonWithType:UIButtonTypeCustom];
218 | [noButton addTarget:self
219 | action:@selector(handleNoGesture:)
220 | forControlEvents:UIControlEventTouchUpInside];
221 | [noButton setTitle:@"No" forState:UIControlStateNormal];
222 | [noButton setTitleColor:[UIColor labelColor] forState:UIControlStateNormal];
223 | noButton.frame = CGRectMake(0, 100, 100, 30);
224 | [popController.view addSubview:noButton];
225 |
226 | UIPopoverPresentationController *popover = popController.popoverPresentationController;
227 | popover.delegate = self;
228 | popover.permittedArrowDirections = UIPopoverArrowDirectionUp;
229 | popover.barButtonItem = respringButtonItem;
230 | //popover.sourceView = sender;
231 | //popover.sourceRect = CGRectMake(0, 0, sender.frame.size.width, sender.frame.size.height);
232 |
233 | [self presentViewController:popController animated:YES completion:nil];
234 |
235 | AudioServicesPlaySystemSound(1519);
236 |
237 | }
238 |
239 | - (void)handleYesGesture:(UIButton *)sender {
240 | AudioServicesPlaySystemSound(1519);
241 |
242 | UIApplication *app = [UIApplication sharedApplication];
243 | [app performSelector:@selector(suspend)];
244 | [NSThread sleepForTimeInterval:1.0];
245 | exit(0);
246 | /* pid_t pid;
247 | const char* args[] = {"killall", "SpringBoard", NULL};
248 | posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL); */
249 | }
250 |
251 | - (void)handleNoGesture:(UIButton *)sender {
252 | [popController dismissViewControllerAnimated:YES completion:nil];
253 | }
254 | @end
255 |
256 | @implementation SETBTNSAppearanceSettings: HBAppearanceSettings
257 |
258 | - (UIColor *)tintColor {
259 |
260 | UIColor *tintDynamicColor = [UIColor colorWithDynamicProvider:^UIColor *(UITraitCollection *traitCollection) {
261 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
262 | return [UIColor colorWithRed:131/255.0f green:156/255.0f blue:186/255.0f alpha:1.0f];
263 | }
264 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
265 | return [UIColor colorWithRed:75/255.0f green:111/255.0f blue:155/255.0f alpha:1.0f];
266 | }
267 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleUnspecified) {
268 | return [UIColor colorWithRed:131/255.0f green:156/255.0f blue:186/255.0f alpha:1.0f];
269 | }
270 | return [UIColor colorWithRed:131/255.0f green:156/255.0f blue:186/255.0f alpha:1.0f];
271 | }];
272 |
273 | return tintDynamicColor;
274 |
275 | }
276 |
277 | - (UIColor *)tableViewCellSeparatorColor {
278 |
279 | return [UIColor clearColor];
280 |
281 | }
282 |
283 | - (UIColor *)tableViewCellBackgroundColor {
284 |
285 | UIColor *tableCellBackgroundColor = [UIColor colorWithDynamicProvider:^UIColor *(UITraitCollection *traitCollection) {
286 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
287 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
288 | }
289 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
290 | return [UIColor colorWithRed:186/255.0f green:204/255.0f blue:211/255.0f alpha:1.0f];
291 | }
292 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleUnspecified) {
293 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
294 | }
295 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
296 | }];
297 |
298 | return tableCellBackgroundColor;
299 |
300 | }
301 |
302 | - (UIColor *)tableViewCellSelectionColor {
303 |
304 | UIColor *tableCellSelectionColor = [UIColor colorWithDynamicProvider:^UIColor *(UITraitCollection *traitCollection) {
305 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
306 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
307 | }
308 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
309 | return [UIColor colorWithRed:186/255.0f green:204/255.0f blue:211/255.0f alpha:1.0f];
310 | }
311 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleUnspecified) {
312 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
313 | }
314 | return [UIColor colorWithRed:83/255.0f green:95/255.0f blue:109/255.0f alpha:1.0f];
315 | }];
316 |
317 | return tableCellSelectionColor;
318 |
319 | }
320 |
321 | - (UIColor *)tableViewCellTextColor {
322 |
323 | UIColor *tableCellTextColor = [UIColor colorWithDynamicProvider:^UIColor *(UITraitCollection *traitCollection) {
324 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
325 | return [UIColor colorWithRed:196/255.0f green:212/255.0f blue:217/255.0f alpha:1.0f];
326 | }
327 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
328 | return [UIColor colorWithRed:94/255.0f green:107/255.0f blue:123/255.0f alpha:1.0f];
329 | }
330 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleUnspecified) {
331 | return [UIColor colorWithRed:196/255.0f green:212/255.0f blue:217/255.0f alpha:1.0f];
332 | }
333 | return [UIColor colorWithRed:196/255.0f green:212/255.0f blue:217/255.0f alpha:1.0f];
334 | }];
335 |
336 | return tableCellTextColor;
337 |
338 | }
339 |
340 |
341 | @end
342 |
--------------------------------------------------------------------------------
/Tweak.xm:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "SparkColourPickerUtils.h"
4 | #import "SparkColourPickerView.h"
5 | #import
6 | #import
7 | #import
8 | #import
9 | #import "NSTask.h"
10 |
11 | UIViewController *respringPopController;
12 | UIViewController *safeModePopController;
13 | UIViewController *ldrestartPopController;
14 | UIViewController *lpmPopController;
15 | UIButton *darkModeButton;
16 |
17 | static NSMutableDictionary *colorDictionary;
18 | static NSString *nsNotificationString = @"com.nahtedetihw.settingsbuttonsprefs.color/changed";
19 |
20 | UIColor *tintDynamicColor = [UIColor colorWithDynamicProvider:^UIColor *(UITraitCollection *traitCollection) {
21 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
22 | return [SparkColourPickerUtils colourWithString:[colorDictionary objectForKey:@"tintColorDark"] withFallback:@"#FFFFFF"];
23 | }
24 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
25 | return [SparkColourPickerUtils colourWithString:[colorDictionary objectForKey:@"tintColorLight"] withFallback:@"#000000"];
26 | }
27 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleUnspecified) {
28 | return [SparkColourPickerUtils colourWithString:[colorDictionary objectForKey:@"tintColorDark"] withFallback:@"#FFFFFF"];
29 | }
30 | return [UIColor colorWithRed:255/255.0f green:255/255.0f blue:255/255.0f alpha:1.0f];
31 | }];
32 |
33 | UIColor *backgroundDynamicColor = [UIColor colorWithDynamicProvider:^UIColor *(UITraitCollection *traitCollection) {
34 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
35 | return [SparkColourPickerUtils colourWithString:[colorDictionary objectForKey:@"backgroundColorDark"] withFallback:@"#000000"];
36 | }
37 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
38 | return [SparkColourPickerUtils colourWithString:[colorDictionary objectForKey:@"backgroundColorLight"] withFallback:@"#FFFFFF"];
39 | }
40 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleUnspecified) {
41 | return [SparkColourPickerUtils colourWithString:[colorDictionary objectForKey:@"backgroundColorDark"] withFallback:@"#000000"];
42 | }
43 | return [UIColor colorWithRed:0/255.0f green:0/255.0f blue:0/255.0f alpha:1.0f];
44 | }];
45 |
46 | HBPreferences *preferences;
47 | BOOL enable;
48 | BOOL enableLeftButtons;
49 | NSInteger colorStyle;
50 | NSInteger rightButtonStyle;
51 | NSInteger leftButtonStyle;
52 |
53 | %group SettingsButtons
54 |
55 | @interface RespringViewController : UIViewController
56 | @end
57 |
58 | @implementation RespringViewController
59 | - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
60 | traitCollection:(UITraitCollection *)traitCollection {
61 | return UIModalPresentationNone;
62 | }
63 | @end
64 |
65 | @interface SafeModeViewController : UIViewController
66 | @end
67 |
68 | @implementation SafeModeViewController
69 | - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
70 | traitCollection:(UITraitCollection *)traitCollection {
71 | return UIModalPresentationNone;
72 | }
73 | @end
74 |
75 | @interface ldrestartViewController : UIViewController
76 | @end
77 |
78 | @implementation ldrestartViewController
79 | - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
80 | traitCollection:(UITraitCollection *)traitCollection {
81 | return UIModalPresentationNone;
82 | }
83 | @end
84 |
85 | @interface lpmViewController : UIViewController
86 | @end
87 |
88 | @implementation lpmViewController
89 | - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
90 | traitCollection:(UITraitCollection *)traitCollection {
91 | return UIModalPresentationNone;
92 | }
93 | @end
94 |
95 | @interface PSUIPrefsListController : UIViewController
96 | - (void)respringYesGesture:(UIButton *)sender;
97 | - (void)respringNoGesture:(UIButton *)sender;
98 | - (void)respring:(UIButton *)sender;
99 | - (void)safeModeYesGesture:(UIButton *)sender;
100 | - (void)safeModeNoGesture:(UIButton *)sender;
101 | - (void)safeMode:(UIButton *)sender;
102 | - (void)darkMode:(UIButton *)sender;
103 | - (void)flashLight:(UIButton *)sender;
104 | - (void)ldrestartYesGesture:(UIButton *)sender;
105 | - (void)ldrestartNoGesture:(UIButton *)sender;
106 | - (void)ldrestart:(UIButton *)sender;
107 | @end
108 |
109 | @interface UISUserInterfaceStyleMode : NSObject
110 | @property (nonatomic, assign) long long modeValue;
111 | @end
112 |
113 | @interface UIColor (Private)
114 | + (id)tableCellGroupedBackgroundColor;
115 | @end
116 |
117 | @interface _CDBatterySaver
118 | -(id)batterySaver;
119 | -(BOOL)setPowerMode:(long long)arg1 error:(id *)arg2;
120 | @end
121 |
122 | %hook PSUIPrefsListController
123 |
124 | - (void)viewDidLoad {
125 | %orig;
126 |
127 | UIButton *respringButton = [UIButton buttonWithType:UIButtonTypeCustom];
128 | respringButton.frame = CGRectMake(0,0,30,30);
129 | respringButton.layer.cornerRadius = respringButton.frame.size.height / 2;
130 | respringButton.layer.masksToBounds = YES;
131 |
132 | if (colorStyle == 0) {
133 | respringButton.backgroundColor = [UIColor tableCellGroupedBackgroundColor];
134 | } else if (colorStyle == 1) {
135 | respringButton.backgroundColor = backgroundDynamicColor;
136 | }
137 |
138 | [respringButton setImage:[[UIImage imageWithContentsOfFile:@"/Library/Application Support/SettingsButtons/respring.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
139 | respringButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
140 | respringButton.imageEdgeInsets = UIEdgeInsetsMake(-2,-2,-2,-2);
141 | [respringButton addTarget:self action:@selector(respring:) forControlEvents:UIControlEventTouchUpInside];
142 |
143 | if (colorStyle == 0) {
144 | respringButton.tintColor = [UIColor labelColor];
145 | } else if (colorStyle == 1) {
146 | respringButton.tintColor = tintDynamicColor;
147 | }
148 |
149 | UIBarButtonItem *respringButtonItem = [[UIBarButtonItem alloc] initWithCustomView:respringButton];
150 |
151 | UIButton *safeModeButton = [UIButton buttonWithType:UIButtonTypeCustom];
152 | safeModeButton.frame = CGRectMake(0,0,30,30);
153 | safeModeButton.layer.cornerRadius = safeModeButton.frame.size.height / 2;
154 | safeModeButton.layer.masksToBounds = YES;
155 |
156 | if (colorStyle == 0) {
157 | safeModeButton.backgroundColor = [UIColor tableCellGroupedBackgroundColor];
158 | } else if (colorStyle == 1) {
159 | safeModeButton.backgroundColor = backgroundDynamicColor;
160 | }
161 |
162 | [safeModeButton setImage:[[UIImage imageWithContentsOfFile:@"/Library/Application Support/SettingsButtons/safemode.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
163 | safeModeButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
164 | safeModeButton.imageEdgeInsets = UIEdgeInsetsMake(-2,-2,-2,-2);
165 | [safeModeButton addTarget:self action:@selector(safeMode:) forControlEvents:UIControlEventTouchUpInside];
166 |
167 | if (colorStyle == 0) {
168 | safeModeButton.tintColor = [UIColor labelColor];
169 | } else if (colorStyle == 1) {
170 | safeModeButton.tintColor = tintDynamicColor;
171 | }
172 |
173 | UIBarButtonItem *safeModeButtonItem = [[UIBarButtonItem alloc] initWithCustomView:safeModeButton];
174 |
175 | darkModeButton = [UIButton buttonWithType:UIButtonTypeCustom];
176 | darkModeButton.frame = CGRectMake(0,0,30,30);
177 | darkModeButton.layer.cornerRadius = darkModeButton.frame.size.height / 2;
178 | darkModeButton.layer.masksToBounds = YES;
179 |
180 | if (colorStyle == 0) {
181 | darkModeButton.backgroundColor = [UIColor tableCellGroupedBackgroundColor];
182 | } else if (colorStyle == 1) {
183 | darkModeButton.backgroundColor = backgroundDynamicColor;
184 | }
185 |
186 | [darkModeButton setImage:[[UIImage imageWithContentsOfFile:@"/Library/Application Support/SettingsButtons/lightmode.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
187 | darkModeButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
188 | [darkModeButton addTarget:self action:@selector(darkMode:) forControlEvents:UIControlEventTouchUpInside];
189 |
190 | if (colorStyle == 0) {
191 | darkModeButton.tintColor = [UIColor labelColor];
192 | } else if (colorStyle == 1) {
193 | darkModeButton.tintColor = tintDynamicColor;
194 | }
195 |
196 | UIBarButtonItem *darkModeButtonItem = [[UIBarButtonItem alloc] initWithCustomView:darkModeButton];
197 |
198 |
199 | UIBarButtonItem *space = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
200 | space.width = 2;
201 |
202 | UIButton *flashLightButton = [UIButton buttonWithType:UIButtonTypeCustom];
203 | flashLightButton.frame = CGRectMake(0,0,30,30);
204 | flashLightButton.layer.cornerRadius = flashLightButton.frame.size.height / 2;
205 | flashLightButton.layer.masksToBounds = YES;
206 |
207 | if (colorStyle == 0) {
208 | flashLightButton.backgroundColor = [UIColor tableCellGroupedBackgroundColor];
209 | } else if (colorStyle == 1) {
210 | flashLightButton.backgroundColor = backgroundDynamicColor;
211 | }
212 |
213 | [flashLightButton setImage:[[UIImage imageWithContentsOfFile:@"/Library/Application Support/SettingsButtons/flashlight.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
214 | flashLightButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
215 | [flashLightButton addTarget:self action:@selector(flashLight:) forControlEvents:UIControlEventTouchUpInside];
216 |
217 | if (colorStyle == 0) {
218 | flashLightButton.tintColor = [UIColor labelColor];
219 | } else if (colorStyle == 1) {
220 | flashLightButton.tintColor = tintDynamicColor;
221 | }
222 |
223 | UIBarButtonItem *flashLightButtonItem = [[UIBarButtonItem alloc] initWithCustomView:flashLightButton];
224 |
225 | UIButton *ldrestartButton = [UIButton buttonWithType:UIButtonTypeCustom];
226 | ldrestartButton.frame = CGRectMake(0,0,30,30);
227 | ldrestartButton.layer.cornerRadius = ldrestartButton.frame.size.height / 2;
228 | ldrestartButton.layer.masksToBounds = YES;
229 |
230 | if (colorStyle == 0) {
231 | ldrestartButton.backgroundColor = [UIColor tableCellGroupedBackgroundColor];
232 | } else if (colorStyle == 1) {
233 | ldrestartButton.backgroundColor = backgroundDynamicColor;
234 | }
235 |
236 | [ldrestartButton setImage:[[UIImage imageWithContentsOfFile:@"/Library/Application Support/SettingsButtons/ldrestart.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
237 | ldrestartButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
238 | [ldrestartButton addTarget:self action:@selector(ldrestart:) forControlEvents:UIControlEventTouchUpInside];
239 |
240 | if (colorStyle == 0) {
241 | ldrestartButton.tintColor = [UIColor labelColor];
242 | } else if (colorStyle == 1) {
243 | ldrestartButton.tintColor = tintDynamicColor;
244 | }
245 |
246 | UIBarButtonItem *ldrestartButtonItem = [[UIBarButtonItem alloc] initWithCustomView:ldrestartButton];
247 |
248 | UIButton *lpmButton = [UIButton buttonWithType:UIButtonTypeCustom];
249 | lpmButton.frame = CGRectMake(0,0,30,30);
250 | lpmButton.layer.cornerRadius = lpmButton.frame.size.height / 2;
251 | lpmButton.layer.masksToBounds = YES;
252 |
253 | if (colorStyle == 0) {
254 | lpmButton.backgroundColor = [UIColor tableCellGroupedBackgroundColor];
255 | } else if (colorStyle == 1) {
256 | lpmButton.backgroundColor = backgroundDynamicColor;
257 | }
258 |
259 | [lpmButton setImage:[[UIImage imageWithContentsOfFile:@"/Library/Application Support/SettingsButtons/lowpower.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
260 | lpmButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
261 | [lpmButton addTarget:self action:@selector(lpm:) forControlEvents:UIControlEventTouchUpInside];
262 |
263 | if (colorStyle == 0) {
264 | lpmButton.tintColor = [UIColor labelColor];
265 | } else if (colorStyle == 1) {
266 | lpmButton.tintColor = tintDynamicColor;
267 | }
268 |
269 | UIBarButtonItem *lpmButtonItem = [[UIBarButtonItem alloc] initWithCustomView:lpmButton];
270 |
271 | NSArray *rightButtons;
272 |
273 | if (rightButtonStyle == 0) {
274 | rightButtons = @[space, respringButtonItem, space, safeModeButtonItem, space, darkModeButtonItem, space];
275 | } else if (rightButtonStyle == 1) {
276 | rightButtons = @[space, respringButtonItem, space, safeModeButtonItem, space, ldrestartButtonItem, space];
277 | } else if (rightButtonStyle == 2) {
278 | rightButtons = @[space, respringButtonItem, space, ldrestartButtonItem, space, darkModeButtonItem, space];
279 | } else if (rightButtonStyle == 3) {
280 | rightButtons = @[space, respringButtonItem, space, flashLightButtonItem, space, darkModeButtonItem, space];
281 | } else if (rightButtonStyle == 4) {
282 | rightButtons = @[space, respringButtonItem, space, flashLightButtonItem, space, safeModeButtonItem, space];
283 | }
284 |
285 | self.navigationItem.rightBarButtonItems = rightButtons;
286 |
287 | NSArray *leftButtons;
288 |
289 | if (leftButtonStyle == 0) {
290 | leftButtons = @[space, lpmButtonItem, space, ldrestartButtonItem, space, flashLightButtonItem, space];
291 | } else if (leftButtonStyle == 1) {
292 | leftButtons = @[space, darkModeButtonItem, space, lpmButtonItem, space, flashLightButtonItem, space];
293 | } else if (leftButtonStyle == 2) {
294 | leftButtons = @[space, safeModeButtonItem, space, lpmButtonItem, space, flashLightButtonItem, space];
295 | } else if (leftButtonStyle == 3) {
296 | leftButtons = @[space, safeModeButtonItem, space, lpmButtonItem, space, ldrestartButtonItem, space];
297 | } else if (leftButtonStyle == 3) {
298 | leftButtons = @[space, darkModeButtonItem, space, lpmButtonItem, space, ldrestartButtonItem, space];
299 | }
300 |
301 | if (enableLeftButtons) {
302 | self.navigationItem.leftBarButtonItems = leftButtons;
303 | }
304 | }
305 |
306 | %new
307 | - (void)respring:(UIButton *)sender {
308 |
309 | respringPopController = [[UIViewController alloc] init];
310 | respringPopController.modalPresentationStyle = UIModalPresentationPopover;
311 | respringPopController.preferredContentSize = CGSizeMake(200,130);
312 |
313 | UILabel *respringLabel = [[UILabel alloc] init];
314 | respringLabel.frame = CGRectMake(10, 20, 180, 60);
315 | respringLabel.numberOfLines = 2;
316 | respringLabel.textAlignment = NSTextAlignmentCenter;
317 | respringLabel.adjustsFontSizeToFitWidth = YES;
318 | respringLabel.font = [UIFont boldSystemFontOfSize:20];
319 | respringLabel.textColor = [UIColor labelColor];
320 | respringLabel.text = @"Are you sure you want to respring?";
321 | [respringPopController.view addSubview:respringLabel];
322 |
323 | UIButton *respringYesButton = [UIButton buttonWithType:UIButtonTypeCustom];
324 | [respringYesButton addTarget:self
325 | action:@selector(respringYesGesture:)
326 | forControlEvents:UIControlEventTouchUpInside];
327 | [respringYesButton setTitle:@"Yes" forState:UIControlStateNormal];
328 | [respringYesButton setTitleColor:[UIColor labelColor] forState:UIControlStateNormal];
329 | respringYesButton.frame = CGRectMake(100, 100, 100, 30);
330 | [respringPopController.view addSubview:respringYesButton];
331 |
332 | UIButton *respringNoButton = [UIButton buttonWithType:UIButtonTypeCustom];
333 | [respringNoButton addTarget:self
334 | action:@selector(respringNoGesture:)
335 | forControlEvents:UIControlEventTouchUpInside];
336 | [respringNoButton setTitle:@"No" forState:UIControlStateNormal];
337 | [respringNoButton setTitleColor:[UIColor labelColor] forState:UIControlStateNormal];
338 | respringNoButton.frame = CGRectMake(0, 100, 100, 30);
339 | [respringPopController.view addSubview:respringNoButton];
340 |
341 | UIPopoverPresentationController *respringPopover = respringPopController.popoverPresentationController;
342 | RespringViewController *vc = [[RespringViewController alloc] init];
343 | respringPopover.delegate = vc;
344 | respringPopover.permittedArrowDirections = UIPopoverArrowDirectionUp;
345 | //respringPopover.barButtonItem = respringButtonItem;
346 | // you can replace the barButtonItem with the below two methods to anchor the popover to a different view
347 | respringPopover.sourceView = sender;
348 | respringPopover.sourceRect = sender.frame;
349 |
350 | [self presentViewController:respringPopController animated:YES completion:nil];
351 |
352 | AudioServicesPlaySystemSound(1519);
353 | }
354 |
355 | %new
356 | - (void)respringYesGesture:(UIButton *)sender {
357 | AudioServicesPlaySystemSound(1521);
358 |
359 | pid_t pid;
360 | const char* args[] = {"sbreload", NULL};
361 | posix_spawn(&pid, "/usr/bin/sbreload", NULL, NULL, (char* const*)args, NULL);
362 | }
363 |
364 | %new
365 | - (void)respringNoGesture:(UIButton *)sender {
366 | [respringPopController dismissViewControllerAnimated:YES completion:nil];
367 | }
368 |
369 | %new
370 | - (void)safeMode:(UIButton *)sender {
371 |
372 | safeModePopController = [[UIViewController alloc] init];
373 | safeModePopController.modalPresentationStyle = UIModalPresentationPopover;
374 | safeModePopController.preferredContentSize = CGSizeMake(200,130);
375 |
376 | UILabel *safeModeLabel = [[UILabel alloc] init];
377 | safeModeLabel.frame = CGRectMake(20, 20, 160, 60);
378 | safeModeLabel.numberOfLines = 2;
379 | safeModeLabel.textAlignment = NSTextAlignmentCenter;
380 | safeModeLabel.adjustsFontSizeToFitWidth = YES;
381 | safeModeLabel.font = [UIFont boldSystemFontOfSize:20];
382 | safeModeLabel.textColor = [UIColor labelColor];
383 | safeModeLabel.text = @"Are you sure you want to enter Safe Mode?";
384 | [safeModePopController.view addSubview:safeModeLabel];
385 |
386 | UIButton *safeModeYesButton = [UIButton buttonWithType:UIButtonTypeCustom];
387 | [safeModeYesButton addTarget:self
388 | action:@selector(safeModeYesGesture:)
389 | forControlEvents:UIControlEventTouchUpInside];
390 | [safeModeYesButton setTitle:@"Yes" forState:UIControlStateNormal];
391 | [safeModeYesButton setTitleColor:[UIColor labelColor] forState:UIControlStateNormal];
392 | safeModeYesButton.frame = CGRectMake(100, 100, 100, 30);
393 | [safeModePopController.view addSubview:safeModeYesButton];
394 |
395 | UIButton *safeModeNoButton = [UIButton buttonWithType:UIButtonTypeCustom];
396 | [safeModeNoButton addTarget:self
397 | action:@selector(safeModeNoGesture:)
398 | forControlEvents:UIControlEventTouchUpInside];
399 | [safeModeNoButton setTitle:@"No" forState:UIControlStateNormal];
400 | [safeModeNoButton setTitleColor:[UIColor labelColor] forState:UIControlStateNormal];
401 | safeModeNoButton.frame = CGRectMake(0, 100, 100, 30);
402 | [safeModePopController.view addSubview:safeModeNoButton];
403 |
404 | UIPopoverPresentationController *safeModePopover = safeModePopController.popoverPresentationController;
405 | SafeModeViewController *vc = [[SafeModeViewController alloc] init];
406 | safeModePopover.delegate = vc;
407 | safeModePopover.permittedArrowDirections = UIPopoverArrowDirectionUp;
408 | //safeModePopover.barButtonItem = safeModeButtonItem;
409 | // you can replace the barButtonItem with the below two methods to anchor the popover to a different view
410 | safeModePopover.sourceView = sender;
411 | safeModePopover.sourceRect = CGRectMake(0, 0, sender.frame.size.width, sender.frame.size.height);
412 |
413 | [self presentViewController:safeModePopController animated:YES completion:nil];
414 |
415 | AudioServicesPlaySystemSound(1519);
416 | }
417 |
418 | %new
419 | - (void)safeModeYesGesture:(UIButton *)sender {
420 | AudioServicesPlaySystemSound(1521);
421 |
422 | pid_t pid;
423 | const char *args[] = {"killall", "-SEGV", "SpringBoard", NULL};
424 | posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char * const *)args, NULL);
425 | }
426 |
427 | %new
428 | - (void)safeModeNoGesture:(UIButton *)sender {
429 | [safeModePopController dismissViewControllerAnimated:YES completion:nil];
430 | }
431 |
432 | %new
433 | - (void)darkMode:(UIButton *)sender {
434 |
435 | AudioServicesPlaySystemSound(1519);
436 |
437 | BOOL darkEnabled = ([UITraitCollection currentTraitCollection].userInterfaceStyle == UIUserInterfaceStyleDark);
438 |
439 | UISUserInterfaceStyleMode *styleMode = [[%c(UISUserInterfaceStyleMode) alloc] init];
440 | if (darkEnabled) {
441 | styleMode.modeValue = 1;
442 | [UIView animateWithDuration:1.0 delay:0 options:nil animations:^{
443 | [darkModeButton setImage:[[UIImage imageWithContentsOfFile:@"/Library/Application Support/SettingsButtons/darkmode.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
444 | darkModeButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
445 | } completion:nil];
446 | } else if (!darkEnabled) {
447 | styleMode.modeValue = 2;
448 | [UIView animateWithDuration:1.0 delay:0 options:nil animations:^{
449 | [darkModeButton setImage:[[UIImage imageWithContentsOfFile:@"/Library/Application Support/SettingsButtons/lightmode.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
450 | darkModeButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
451 | } completion:nil];
452 | }
453 | }
454 |
455 | %new
456 | - (void)flashLight:(UIButton *)sender {
457 | AVCaptureDevice *flashLight = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
458 | if ([flashLight isTorchAvailable] && [flashLight isTorchModeSupported:AVCaptureTorchModeOn]) {
459 | BOOL success = [flashLight lockForConfiguration:nil];
460 | if (success) {
461 | if ([flashLight isTorchActive]) {
462 | [flashLight setTorchMode:AVCaptureTorchModeOff];
463 | } else {
464 | [flashLight setTorchMode:AVCaptureTorchModeOn];
465 | }
466 | [flashLight unlockForConfiguration];
467 | }
468 | }
469 | AudioServicesPlaySystemSound(1519);
470 | }
471 |
472 | %new
473 | - (void)ldrestart:(UIButton *)sender {
474 |
475 | ldrestartPopController = [[UIViewController alloc] init];
476 | ldrestartPopController.modalPresentationStyle = UIModalPresentationPopover;
477 | ldrestartPopController.preferredContentSize = CGSizeMake(200,130);
478 |
479 | UILabel *ldrestartLabel = [[UILabel alloc] init];
480 | ldrestartLabel.frame = CGRectMake(20, 20, 160, 60);
481 | ldrestartLabel.numberOfLines = 2;
482 | ldrestartLabel.textAlignment = NSTextAlignmentCenter;
483 | ldrestartLabel.adjustsFontSizeToFitWidth = YES;
484 | ldrestartLabel.font = [UIFont boldSystemFontOfSize:20];
485 | ldrestartLabel.textColor = [UIColor labelColor];
486 | ldrestartLabel.text = @"Are you sure you want to Soft Reboot?";
487 | [ldrestartPopController.view addSubview:ldrestartLabel];
488 |
489 | UIButton *ldrestartYesButton = [UIButton buttonWithType:UIButtonTypeCustom];
490 | [ldrestartYesButton addTarget:self
491 | action:@selector(ldrestartYesGesture:)
492 | forControlEvents:UIControlEventTouchUpInside];
493 | [ldrestartYesButton setTitle:@"Yes" forState:UIControlStateNormal];
494 | [ldrestartYesButton setTitleColor:[UIColor labelColor] forState:UIControlStateNormal];
495 | ldrestartYesButton.frame = CGRectMake(100, 100, 100, 30);
496 | [ldrestartPopController.view addSubview:ldrestartYesButton];
497 |
498 | UIButton *ldrestartNoButton = [UIButton buttonWithType:UIButtonTypeCustom];
499 | [ldrestartNoButton addTarget:self
500 | action:@selector(ldrestartNoGesture:)
501 | forControlEvents:UIControlEventTouchUpInside];
502 | [ldrestartNoButton setTitle:@"No" forState:UIControlStateNormal];
503 | [ldrestartNoButton setTitleColor:[UIColor labelColor] forState:UIControlStateNormal];
504 | ldrestartNoButton.frame = CGRectMake(0, 100, 100, 30);
505 | [ldrestartPopController.view addSubview:ldrestartNoButton];
506 |
507 | UIPopoverPresentationController *ldrestartPopover = ldrestartPopController.popoverPresentationController;
508 | ldrestartViewController *vc = [[ldrestartViewController alloc] init];
509 | ldrestartPopover.delegate = vc;
510 | ldrestartPopover.permittedArrowDirections = UIPopoverArrowDirectionUp;
511 | //ldrestartPopover.barButtonItem = ldrestartButtonItem;
512 | // you can replace the barButtonItem with the below two methods to anchor the popover to a different view
513 | ldrestartPopover.sourceView = sender;
514 | ldrestartPopover.sourceRect = CGRectMake(0, 0, sender.frame.size.width, sender.frame.size.height);
515 |
516 | [self presentViewController:ldrestartPopController animated:YES completion:nil];
517 |
518 | AudioServicesPlaySystemSound(1519);
519 | }
520 |
521 | %new
522 | - (void)ldrestartYesGesture:(UIButton *)sender {
523 | AudioServicesPlaySystemSound(1521);
524 |
525 | NSTask *t = [[NSTask alloc] init];
526 | [t setLaunchPath:@"/usr/bin/sreboot"];
527 | [t setArguments:[NSArray arrayWithObjects:@"ldrestart", nil]];
528 | [t launch];
529 | }
530 |
531 | %new
532 | - (void)ldrestartNoGesture:(UIButton *)sender {
533 | [ldrestartPopController dismissViewControllerAnimated:YES completion:nil];
534 | }
535 |
536 | %new
537 | - (void)lpm:(UIButton *)sender {
538 |
539 | lpmPopController = [[UIViewController alloc] init];
540 | lpmPopController.modalPresentationStyle = UIModalPresentationPopover;
541 | lpmPopController.preferredContentSize = CGSizeMake(200,130);
542 |
543 | UILabel *lpmLabel = [[UILabel alloc] init];
544 | lpmLabel.frame = CGRectMake(20, 20, 160, 60);
545 | lpmLabel.numberOfLines = 2;
546 | lpmLabel.textAlignment = NSTextAlignmentCenter;
547 | lpmLabel.adjustsFontSizeToFitWidth = YES;
548 | lpmLabel.font = [UIFont boldSystemFontOfSize:20];
549 | lpmLabel.textColor = [UIColor labelColor];
550 | lpmLabel.text = @"Are you sure you want to toggle Low Power Mode?";
551 | [lpmPopController.view addSubview:lpmLabel];
552 |
553 | UIButton *lpmYesButton = [UIButton buttonWithType:UIButtonTypeCustom];
554 | [lpmYesButton addTarget:self
555 | action:@selector(lpmYesGesture:)
556 | forControlEvents:UIControlEventTouchUpInside];
557 | [lpmYesButton setTitle:@"Yes" forState:UIControlStateNormal];
558 | [lpmYesButton setTitleColor:[UIColor labelColor] forState:UIControlStateNormal];
559 | lpmYesButton.frame = CGRectMake(100, 100, 100, 30);
560 | [lpmPopController.view addSubview:lpmYesButton];
561 |
562 | UIButton *lpmNoButton = [UIButton buttonWithType:UIButtonTypeCustom];
563 | [lpmNoButton addTarget:self
564 | action:@selector(lpmNoGesture:)
565 | forControlEvents:UIControlEventTouchUpInside];
566 | [lpmNoButton setTitle:@"No" forState:UIControlStateNormal];
567 | [lpmNoButton setTitleColor:[UIColor labelColor] forState:UIControlStateNormal];
568 | lpmNoButton.frame = CGRectMake(0, 100, 100, 30);
569 | [lpmPopController.view addSubview:lpmNoButton];
570 |
571 | UIPopoverPresentationController *lpmPopover = lpmPopController.popoverPresentationController;
572 | lpmViewController *vc = [[lpmViewController alloc] init];
573 | lpmPopover.delegate = vc;
574 | lpmPopover.permittedArrowDirections = UIPopoverArrowDirectionUp;
575 | //lpmPopover.barButtonItem = lpmButtonItem;
576 | // you can replace the barButtonItem with the below two methods to anchor the popover to a different view
577 | lpmPopover.sourceView = sender;
578 | lpmPopover.sourceRect = CGRectMake(0, 0, sender.frame.size.width, sender.frame.size.height);
579 |
580 | [self presentViewController:lpmPopController animated:YES completion:nil];
581 |
582 | AudioServicesPlaySystemSound(1519);
583 | }
584 |
585 | %new
586 | - (void)lpmYesGesture:(UIButton *)sender {
587 | AudioServicesPlaySystemSound(1521);
588 | BOOL success = NO;
589 | if ([[%c(NSProcessInfo) processInfo] isLowPowerModeEnabled]) {
590 | [[%c(_CDBatterySaver) batterySaver] setPowerMode:0 error:nil];
591 | success = YES;
592 | } else {
593 | [[%c(_CDBatterySaver) batterySaver] setPowerMode:1 error:nil];
594 | success = YES;
595 | }
596 |
597 | if (success == YES) {
598 | [self dismissViewControllerAnimated:ldrestartPopController completion:nil];
599 | }
600 | }
601 |
602 | %new
603 | - (void)lpmNoGesture:(UIButton *)sender {
604 | [lpmPopController dismissViewControllerAnimated:YES completion:nil];
605 | }
606 | %end
607 |
608 | %hook UIApplication
609 | -(void)applicationWillSuspend {
610 | %orig;
611 | [self.keyWindow.rootViewController dismissViewControllerAnimated:respringPopController completion:nil];
612 | [self.keyWindow.rootViewController dismissViewControllerAnimated:safeModePopController completion:nil];
613 | [self.keyWindow.rootViewController dismissViewControllerAnimated:ldrestartPopController completion:nil];
614 | [self.keyWindow.rootViewController dismissViewControllerAnimated:lpmPopController completion:nil];
615 | }
616 | %end
617 |
618 | %end
619 |
620 | static void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
621 | // Notification for colors
622 | colorDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/private/var/mobile/Library/Preferences/com.nahtedetihw.settingsbuttonsprefs.color.plist"];
623 | }
624 |
625 | %ctor {
626 | notificationCallback(NULL, NULL, NULL, NULL, NULL);
627 | CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, notificationCallback, (CFStringRef)nsNotificationString, NULL, CFNotificationSuspensionBehaviorCoalesce);
628 |
629 | preferences = [[HBPreferences alloc] initWithIdentifier:@"com.nahtedetihw.settingsbuttonsprefs"];
630 | [preferences registerBool:&enable default:NO forKey:@"enable"];
631 | [preferences registerBool:&enableLeftButtons default:NO forKey:@"enableLeftButtons"];
632 | [preferences registerInteger:&colorStyle default:0 forKey:@"colorStyle"];
633 | [preferences registerInteger:&rightButtonStyle default:0 forKey:@"rightButtonStyle"];
634 | [preferences registerInteger:&leftButtonStyle default:0 forKey:@"leftButtonStyle"];
635 |
636 | if (enable) {
637 | %init(SettingsButtons);
638 | return;
639 | }
640 | return;
641 | }
642 |
--------------------------------------------------------------------------------