diff --git a/Makefile b/Makefile
index 6387a69..0df0f9a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,18 @@
ARCHS = arm64 arm64e
-SDK = iPhoneOS13.0
+SDK = iPhoneOS12.4
FINALPACKAGE = 1
-export TARGET = iphone:clang:13.0:latest
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = ZenithDark
ZenithDark_FILES = Tweak.xm
-ZenithDark_CFLAGS = -fobjc-arc
ZenithDark_FRAMEWORKS = UIKit CoreGraphics
include $(THEOS_MAKE_PATH)/tweak.mk
-after-install::
- install.exec "sbreload"
SUBPROJECTS += zenithdarkprefs
include $(THEOS_MAKE_PATH)/aggregate.mk
+
+after-install::
+ install.exec "sbreload"
\ No newline at end of file
diff --git a/Tweak.xm b/Tweak.xm
index fbd9fd6..a0d5df3 100644
--- a/Tweak.xm
+++ b/Tweak.xm
@@ -11,27 +11,14 @@ Written for Cooper Hull, @(mac-user669).
#import "ZenithDark.h"
-static BOOL enabled;
-static void loadPrefs() {
- static NSMutableDictionary *settings;
-
- CFArrayRef keyList = CFPreferencesCopyKeyList(CFSTR("com.mac-user669.zenithdarkprefs"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
- if (keyList) {
- settings = (NSMutableDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, CFSTR("com.mac-user669.zenithdarkprefs"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
- CFRelease(keyList);
- } else {
- settings = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.mac-user669.zenithdarkprefs.plist"];
- }
-
- enabled = [([settings objectForKey:@"enabled"] ? [settings objectForKey:@"enabled"] : @(YES)) boolValue];
-}
-
// We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView”
%hook ZNGrabberAccessoryView
- // this is called when iOS 13's dark mode is enabled!
+
+// this is called when iOS 13's dark mode is enabled!
-(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
- if (enabled) {
- %orig(previousTraitCollection);
+ %orig(previousTraitCollection);
+ if (kEnabled) {
+ // if the tweak is enabled and the version is iOS 13 or later run our code
if (@available(iOS 13, *)) {
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
[self setBackgroundColor:kDarkModeColor];
@@ -39,41 +26,73 @@ static void loadPrefs() {
else {
[self setBackgroundColor:kLightModeColor];
- }
}
}
- %orig;
}
+else {
+ %orig(previousTraitCollection);
+}
+
+}
+
+
+
// the method we modify is this method that is called from UIImageView to set the backgroundColor of the image view.
// Since the grabber view is of type UIImageView we can modify this method :)
-(void)setBackgroundColor:(UIColor *)backgroundColor {
- if (enabled) {
+ %orig;
+ if (kEnabled) {
// by default have our tweak overide this.
if (@available(iOS 13, *)) {
if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
%orig(kDarkModeColor);
}
+ }
else {
%orig;
- }
}
}
- %orig;
}
-
// we need to make sure we tell theos that we are finished hooking this class not doing so with cause the end of the world :P
%end
+
+// Load preferences to make sure changes are written to the plist
+static void loadPrefs() {
+
+ // Thanks to skittyblock!
+ CFArrayRef keyList = CFPreferencesCopyKeyList(CFSTR("com.mac-user669.zenithdark"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+ if(keyList) {
+ prefs = (NSMutableDictionary *)CFPreferencesCopyMultiple(keyList, CFSTR("com.mac-user669.zenithdark"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+ CFRelease(keyList);
+ } else {
+ prefs = nil;
+ }
+
+ if (!prefs) {
+ prefs = [NSMutableDictionary dictionaryWithContentsOfFile:PLIST_PATH];
+
+ }
+ //our preference values that write to a plist file when a user selects somethings
+ kEnabled = [([prefs objectForKey:@"kEnabled"] ?: @(YES)) boolValue];
+}
+
+
+// thanks to skittyblock!
+static void PreferencesChangedCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
+ loadPrefs();
+}
+
// our constructor
%ctor {
-
-loadPrefs();
-
-// We use this to make sure we load Zenith's dynamic library at runtime so we can modify it with our tweak.
+ // load our prefs
+ loadPrefs();
+ CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback) PreferencesChangedCallback, CFSTR("com.mac-user669.zenithdark.prefschanged"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
+ // We use this to make sure we load Zenith's dynamic library at runtime so we can modify it with our tweak.
dlopen ("/Library/MobileSubstrate/DynamicLibraries/Zenith.dylib", RTLD_NOW);
}
\ No newline at end of file
diff --git a/ZenithDark.h b/ZenithDark.h
index c14944a..f88a3ba 100644
--- a/ZenithDark.h
+++ b/ZenithDark.h
@@ -4,7 +4,7 @@ Dark Mode for Zenith's Grabber view!
Copyright 2020 J.K. Hayslip (@iKilledAppl3) & ToxicAppl3 INSDC/iKilledAppl3 LLC.
All code was written for learning purposes and credit must be given to the original author.
-Written for Cooper Hull, @(mac-user669).
+Written for Cooper Hull, (@mac-user669).
ZenithDark Header file to keep the tweak.x file clean!
@@ -19,8 +19,17 @@ ZenithDark Header file to keep the tweak.x file clean!
@interface ZNGrabberAccessoryView : UIImageView
@end
+// a boolean value to store to the tweak's property list path to see if the user has enabled or disabled the tweak.
+BOOL kEnabled;
+
+//Prefs dictionary
+NSMutableDictionary *prefs;
+
// Dark Zenith color we are using macros so we can call it later if need be.
#define kDarkModeColor [UIColor colorWithWhite:0.0 alpha:0.44]
// Stock Zenith color we are using macros so we can call it later if need be.
#define kLightModeColor [UIColor colorWithWhite:1.0 alpha:0.7]
+
+// the PLIST path where all user settings are stored.
+#define PLIST_PATH @"/var/mobile/Library/Preferences/com.mac-user669.zenithdark.plist"
diff --git a/control b/control
index d98404b..adde39c 100644
--- a/control
+++ b/control
@@ -1,8 +1,8 @@
Package: com.mac-user669.zenithdark
-Version: 1.0
+Version: 1.0.1-1
Architecture: iphoneos-arm
Maintainer: mac-user669
-Depends: mobilesubstrate, com.muirey03.zenith, firmware (>=13.0)
+Depends: mobilesubstrate, preferenceloader, com.muirey03.zenith, firmware (>=13.0)
Section: Tweaks
Description: Changes Zeniths tabs to a dark blur
Author: mac-user669
diff --git a/layout/Library/Application Support/ZenithDark/ZNDark.png b/layout/Library/Application Support/ZenithDark/ZNDark.png
new file mode 100644
index 0000000..0bff729
Binary files /dev/null and b/layout/Library/Application Support/ZenithDark/ZNDark.png differ
diff --git a/packages/com.mac-user669.zenithdark_1.0.1-1_iphoneos-arm.deb b/packages/com.mac-user669.zenithdark_1.0.1-1_iphoneos-arm.deb
new file mode 100644
index 0000000..6d5828d
Binary files /dev/null and b/packages/com.mac-user669.zenithdark_1.0.1-1_iphoneos-arm.deb differ
diff --git a/packages/com.mac-user669.zenithdark_1.0_iphoneos-arm.deb b/packages/com.mac-user669.zenithdark_1.0_iphoneos-arm.deb
deleted file mode 100644
index 6ac9a87..0000000
Binary files a/packages/com.mac-user669.zenithdark_1.0_iphoneos-arm.deb and /dev/null differ
diff --git a/zenithdarkprefs/Makefile b/zenithdarkprefs/Makefile
index aab3c31..9bc4bca 100644
--- a/zenithdarkprefs/Makefile
+++ b/zenithdarkprefs/Makefile
@@ -1,14 +1,14 @@
+ARCHS = arm64 arm64e
+SDK = iPhoneOS12.4
+FINALPACKAGE = 1
+
include $(THEOS)/makefiles/common.mk
-ARCHS = arm64 arm64e
-export TARGET = iphone:clang:13.0:latest
BUNDLE_NAME = ZenithDarkPrefs
-
-ZenithDarkPrefs_FILES = ZnthDrkRootListController.m
+ZenithDarkPrefs_FILES = ZNDarkPrefsRootListController.m
ZenithDarkPrefs_INSTALL_PATH = /Library/PreferenceBundles
ZenithDarkPrefs_FRAMEWORKS = UIKit
ZenithDarkPrefs_PRIVATE_FRAMEWORKS = Preferences
-ZenithDarkPrefs_CFLAGS = -fobjc-arc
include $(THEOS_MAKE_PATH)/bundle.mk
diff --git a/zenithdarkprefs/Resources/Info.plist b/zenithdarkprefs/Resources/Info.plist
index 86d931a..d1edb37 100644
--- a/zenithdarkprefs/Resources/Info.plist
+++ b/zenithdarkprefs/Resources/Info.plist
@@ -19,6 +19,6 @@
CFBundleVersion
1.0
NSPrincipalClass
- ZnthDrkRootListController
+ ZNDarkPrefsRootListController
diff --git a/zenithdarkprefs/Resources/Root.plist b/zenithdarkprefs/Resources/Root.plist
index 727bd0f..92a0be5 100644
--- a/zenithdarkprefs/Resources/Root.plist
+++ b/zenithdarkprefs/Resources/Root.plist
@@ -8,35 +8,92 @@
cell
PSGroupCell
label
- Enable
+ Enable Tweak
+ footerText
+ Enable to give Zenith's pull tabs a dark look!
+ PostNotification
+ com.mac-user669.zenithdark.prefschanged
cell
PSSwitchCell
default
defaults
- com.mac-user669.zenithdarkprefs
+ com.mac-user669.zenithdark
key
- enabled
+ kEnabled
label
Enable
-
cell
PSGroupCell
+ label
+ Credits
+ footerText
+ Conceptualized by your yours truly.
+
+
+ icon
+ mac-user669.png
+ cell
+ PSButtonCell
+ label
+ mac-user669 (@mac-user669)
+ action
+ followMe
+
+
+ cell
+ PSGroupCell
+ footerText
+ Coded most of the tweak.
+
+
+ icon
+ iKA.png
+ cell
+ PSButtonCell
+ label
+ J.K. Hayslip (@iKilledAppl3)
+ action
+ followiKA
+
+
+ cell
+ PSGroupCell
+ footerText
+ Helped with some of our preferences code and amongst other things.
+
+
+ icon
+ skitty.png
+ cell
+ PSButtonCell
+ label
+ Skitty (@skittyblock)
+ action
+ followSkitty
+
+
+ cell
+ PSGroupCell
+ label
+ Apply Changes
+ footerText
+ A Respring is needed to apply changes!
cell
PSButtonCell
label
- @mac_user669
+ Respring
action
- openTwitter
+ doAFancyRespring
title
ZenithDark
-
\ No newline at end of file
+
diff --git a/zenithdarkprefs/Resources/ZenithDark@2x.png b/zenithdarkprefs/Resources/ZenithDark@2x.png
new file mode 100644
index 0000000..232fbdb
Binary files /dev/null and b/zenithdarkprefs/Resources/ZenithDark@2x.png differ
diff --git a/zenithdarkprefs/Resources/ZenithDark@3x.png b/zenithdarkprefs/Resources/ZenithDark@3x.png
new file mode 100644
index 0000000..8052ee7
Binary files /dev/null and b/zenithdarkprefs/Resources/ZenithDark@3x.png differ
diff --git a/zenithdarkprefs/Resources/iKA@2x.png b/zenithdarkprefs/Resources/iKA@2x.png
new file mode 100644
index 0000000..b050795
Binary files /dev/null and b/zenithdarkprefs/Resources/iKA@2x.png differ
diff --git a/zenithdarkprefs/Resources/iKA@3x.png b/zenithdarkprefs/Resources/iKA@3x.png
new file mode 100644
index 0000000..accf143
Binary files /dev/null and b/zenithdarkprefs/Resources/iKA@3x.png differ
diff --git a/zenithdarkprefs/Resources/mac-user669@2x.png b/zenithdarkprefs/Resources/mac-user669@2x.png
new file mode 100644
index 0000000..d3041a4
Binary files /dev/null and b/zenithdarkprefs/Resources/mac-user669@2x.png differ
diff --git a/zenithdarkprefs/Resources/mac-user669@3x.png b/zenithdarkprefs/Resources/mac-user669@3x.png
new file mode 100644
index 0000000..882a9cc
Binary files /dev/null and b/zenithdarkprefs/Resources/mac-user669@3x.png differ
diff --git a/zenithdarkprefs/Resources/skitty@2x.png b/zenithdarkprefs/Resources/skitty@2x.png
new file mode 100644
index 0000000..dbc4ef6
Binary files /dev/null and b/zenithdarkprefs/Resources/skitty@2x.png differ
diff --git a/zenithdarkprefs/Resources/skitty@3x.png b/zenithdarkprefs/Resources/skitty@3x.png
new file mode 100644
index 0000000..c1cef59
Binary files /dev/null and b/zenithdarkprefs/Resources/skitty@3x.png differ
diff --git a/zenithdarkprefs/ZNDarkPrefsRootListController.h b/zenithdarkprefs/ZNDarkPrefsRootListController.h
new file mode 100644
index 0000000..bf77975
--- /dev/null
+++ b/zenithdarkprefs/ZNDarkPrefsRootListController.h
@@ -0,0 +1,35 @@
+#import
+@import UIKit;
+
+// image for share button
+
+#define kImagePath @"/Library/Application Support/ZenithDark/ZNDark.png"
+
+@interface ZNDarkPrefsRootListController : PSListController
+@property (nonatomic, strong) UIBlurEffect *respringBlur;
+@property (nonatomic, strong) UIVisualEffectView *respringEffectView;
+@property (nonatomic, strong) UIWindow *mainAppRootWindow;
+@end
+
+
+// we use this to respring our device!
+@interface NSTask : NSObject
+@property (copy) NSArray *arguments;
+@property (copy) NSString *currentDirectoryPath;
+@property (copy) NSDictionary *environment;
+@property (copy) NSString *launchPath;
+@property (readonly) int processIdentifier;
+@property (retain) id standardError;
+@property (retain) id standardInput;
+@property (retain) id standardOutput;
++ (id)currentTaskDictionary;
++ (id)launchedTaskWithDictionary:(id)arg1;
++ (id)launchedTaskWithLaunchPath:(id)arg1 arguments:(id)arg2;
+- (id)init;
+- (void)interrupt;
+- (bool)isRunning;
+- (void)launch;
+- (bool)resume;
+- (bool)suspend;
+- (void)terminate;
+@end
diff --git a/zenithdarkprefs/ZNDarkPrefsRootListController.m b/zenithdarkprefs/ZNDarkPrefsRootListController.m
new file mode 100644
index 0000000..03f4d37
--- /dev/null
+++ b/zenithdarkprefs/ZNDarkPrefsRootListController.m
@@ -0,0 +1,101 @@
+#import "ZNDarkPrefsRootListController.h"
+
+@implementation ZNDarkPrefsRootListController
+
+-(void)viewWillAppear:(BOOL)animated {
+ [super viewWillAppear:animated];
+
+ // share button for our tweak :P
+ self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(shareTapped)];
+
+
+}
+
+
+//share button action
+- (void)shareTapped {
+
+ NSString *shareText = @"Turn off the lights! It's too bright! Get dark tabs for #Zenith (@Muirey03) by using #ZenithDark from @mac_user669 and @iKilledAppl3! https://mac-user669.github.io/repo/";
+ UIImage *image = [UIImage imageWithContentsOfFile:kImagePath];
+ NSArray * itemsToShare = @[shareText, image];
+
+ UIActivityViewController *controller = [[UIActivityViewController alloc]initWithActivityItems:itemsToShare applicationActivities:nil];
+
+ // and present it
+ [self presentActivityController:controller];
+}
+
+- (void)presentActivityController:(UIActivityViewController *)controller {
+
+ // for iPad: make the presentation a Popover
+ controller.modalPresentationStyle = UIModalPresentationPopover;
+ [self presentViewController:controller animated:YES completion:nil];
+
+ UIPopoverPresentationController *popController = [controller popoverPresentationController];
+ popController.permittedArrowDirections = UIPopoverArrowDirectionAny;
+ popController.barButtonItem = self.navigationItem.rightBarButtonItem;
+
+}
+
+- (NSArray *)specifiers {
+ if (!_specifiers) {
+ _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
+ }
+
+ return _specifiers;
+}
+
+
+-(void)followMe {
+ NSURL *twitter = [NSURL URLWithString:@"https://twitter.com/mac_user669"];
+ [[UIApplication sharedApplication] openURL:twitter options:@{} completionHandler:nil];
+}
+
+-(void)followiKA {
+ NSURL *twitter = [NSURL URLWithString:@"https://twitter.com/iKilledAppl3"];
+ [[UIApplication sharedApplication] openURL:twitter options:@{} completionHandler:nil];
+}
+
+-(void)followSkitty {
+ NSURL *twitter = [NSURL URLWithString:@"https://twitter.com/SkittyBlock"];
+ [[UIApplication sharedApplication] openURL:twitter options:@{} completionHandler:nil];
+}
+
+
+-(void)respring {
+ NSTask *task = [[[NSTask alloc] init] autorelease];
+ [task setLaunchPath:@"/usr/bin/killall"];
+ [task setArguments:[NSArray arrayWithObjects:@"backboardd", nil]];
+ [task launch];
+
+}
+
+-(void)doAFancyRespring {
+
+ UIAlertController *confirmRespringAlert = [UIAlertController alertControllerWithTitle:@"Apply Settings?" message:@"This will respring your device." preferredStyle:UIAlertControllerStyleActionSheet];
+ UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"Respring" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+
+ // blur then respring our device!
+ self.mainAppRootWindow = [UIApplication sharedApplication].keyWindow;
+ self.respringBlur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
+ self.respringEffectView = [[UIVisualEffectView alloc] initWithEffect:self.respringBlur];
+ self.respringEffectView.frame = [[UIScreen mainScreen] bounds];
+ [self.mainAppRootWindow addSubview:self.respringEffectView];
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationDuration:5.0];
+ [self.respringEffectView setAlpha:0];
+ [UIView commitAnimations];
+
+ [self performSelector:@selector(respring) withObject:nil afterDelay:3.0];
+
+ }];
+
+ UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
+
+ [confirmRespringAlert addAction:cancel];
+ [confirmRespringAlert addAction:confirm];
+
+ [self presentViewController:confirmRespringAlert animated:YES completion:nil];
+}
+
+@end
diff --git a/zenithdarkprefs/ZnthDrkRootListController.h b/zenithdarkprefs/ZnthDrkRootListController.h
deleted file mode 100644
index 07cc78a..0000000
--- a/zenithdarkprefs/ZnthDrkRootListController.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#import
-
-@interface ZnthDrkRootListController : PSListController
-
-@end
diff --git a/zenithdarkprefs/ZnthDrkRootListController.m b/zenithdarkprefs/ZnthDrkRootListController.m
deleted file mode 100644
index 4c559f8..0000000
--- a/zenithdarkprefs/ZnthDrkRootListController.m
+++ /dev/null
@@ -1,40 +0,0 @@
-#import "ZnthDrkRootListController.h"
-#import
-@implementation ZnthDrkRootListController
-
-- (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- UIBarButtonItem *applyButton = [[UIBarButtonItem alloc] initWithTitle:@"Apply" style:UIBarButtonItemStylePlain target:self action:@selector(respringDevice)];
- self.navigationItem.rightBarButtonItem = applyButton;
-}
-
-- (NSArray *)specifiers {
- if (!_specifiers) {
- _specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self];
- }
-
- return _specifiers;
-}
-
-- (void) respringDevice {
- UIAlertController *confirmRespringAlert = [UIAlertController alertControllerWithTitle:@"Apply settings?" message:@"This will respring your device" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- pid_t pid;
- const char *argv[] = {"sbreload", NULL};
- posix_spawn(&pid, "/usr/bin/sbreload", NULL, NULL, (char* const*)argv, NULL);
- }];
-
- UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
-
- [confirmRespringAlert addAction:cancel];
- [confirmRespringAlert addAction:confirm];
-
- [self presentViewController:confirmRespringAlert animated:YES completion:nil];
-}
-
--(void)openTwitter {
- NSURL *twitter = [NSURL URLWithString:@"https://twitter.com/mac_user669"];
- [[UIApplication sharedApplication] openURL:twitter options:@{} completionHandler:nil];
-}
-
-@end
diff --git a/zenithdarkprefs/entry.plist b/zenithdarkprefs/entry.plist
index 9b0cc13..9db8adf 100644
--- a/zenithdarkprefs/entry.plist
+++ b/zenithdarkprefs/entry.plist
@@ -9,13 +9,13 @@
cell
PSLinkCell
detail
- ZnthDrkRootListController
+ ZNDarkPrefsRootListController
icon
- icon.png
+ ZenithDark.png
isController
label
- ZenithDarkPrefs
+ ZenithDark