Skip to content

Commit

Permalink
Updated to v1.0.6
Browse files Browse the repository at this point in the history
Added iPad layout support
Added Slide Over support
Added proper support for nested URLs eg: `tweaks:root=<IDENTIFIER>/<NESTED_IDENTIFIER>`
Added options menu for a few basic settings
Added Changelog and Version check
  • Loading branch information
CreatureSurvive committed Nov 26, 2021
1 parent da87e77 commit 3dd6925
Show file tree
Hide file tree
Showing 34 changed files with 1,293 additions and 300 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import <UIKit/UIViewController.h>
#import <Preferences/PSListController.h>

@class PSSpecifier;
Expand Down
4 changes: 3 additions & 1 deletion Frameworks/Preferences.framework/Headers/PSRootController.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#import <UIKit/UINavigationController.h>

@class PSListController;
@class PSViewController;

@interface PSRootController : UINavigationController

- (instancetype)initWithTitle:(NSString *)title identifier:(NSString *)identifier;

- (void)handleURL:(id)url ;
- (void)pushController:(PSListController *)controller; // < 3.2
- (void)pushController:(PSViewController *)controller; // < 3.2
- (void)suspend;
- (void)setSupportedInterfaceOrientations:(NSUInteger)orientations;

@end
14 changes: 13 additions & 1 deletion Frameworks/Preferences.framework/Headers/PSSpecifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,23 @@ __END_DECLS

@interface PSSpecifier : NSObject {
@public
SEL action;
Class detailControllerClass;
id target;
SEL getter;
SEL setter;
SEL action;
SEL cancel;
SEL _confirmationAction;
SEL _confirmationCancelAction;
SEL _buttonAction;
SEL _controllerLoadAction;
}

+ (instancetype)preferenceSpecifierNamed:(NSString *)identifier target:(id)target set:(SEL)set get:(SEL)get detail:(Class)detail cell:(PSCellType)cellType edit:(Class)edit;
+ (instancetype)emptyGroupSpecifier;
+ (instancetype)groupSpecifierWithName:(NSString *)name;

@property (nonatomic,retain) NSArray * values;
@property (nonatomic, retain) id target;
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *identifier;
Expand All @@ -147,4 +156,7 @@ __END_DECLS
-(SEL)controllerLoadAction;
-(void)performControllerLoadAction;

- (void)setValues:(NSArray *)values titles:(NSArray *)titles;
- (void)setValues:(NSArray *)values titles:(NSArray *)titles shortTitles:(NSArray *)shortTitles;

@end
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export TARGET = iphone:clang:13.0:10.0
export TARGET = iphone:clang:14.4:10.0
export ARCHS = armv7 arm64

DEBUG = 1
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions TweakSettings-App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Expand Down
19 changes: 19 additions & 0 deletions TweakSettings-App/Localizable.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,27 @@

#define ROOT_NAVIGATION_TITLE_KEY @"ROOT_NAVIGATION_TITLE_KEY"
#define ROOT_NAVIGATION_RIGHT_TITLE_KEY @"ROOT_NAVIGATION_RIGHT_TITLE_KEY"
#define ROOT_NAVIGATION_LEFT_TITLE_KEY @"ROOT_NAVIGATION_LEFT_TITLE_KEY"

#define ALERT_CANCEL_TITLE_KEY @"ALERT_CANCEL_TITLE_KEY"
#define ALERT_DISMISS_TITLE_KEY @"ALERT_DISMISS_TITLE_KEY"
#define ALERT_ACTION_MESSAGE_KEY @"ALERT_ACTION_MESSAGE_KEY"

#define ALWAYS_SHOW_SEARCH_BAR_NAME_KEY @"ALWAYS_SHOW_SEARCH_BAR_NAME_KEY"
#define ALWAYS_SHOW_SEARCH_BAR_GROUP_KEY @"ALWAYS_SHOW_SEARCH_BAR_GROUP_KEY"
#define REQUIRE_ACTION_CONFIRMATION_NAME_KEY @"REQUIRE_ACTION_CONFIRMATION_NAME_KEY"
#define REQUIRE_ACTION_CONFIRMATION_GROUP_KEY @"REQUIRE_ACTION_CONFIRMATION_GROUP_KEY"
#define LONG_PRESS_OPENS_SETTINGS_NAME_KEY @"LONG_PRESS_OPENS_SETTINGS_NAME_KEY"
#define LONG_PRESS_OPENS_SETTINGS_GROUP_KEY @"LONG_PRESS_OPENS_SETTINGS_GROUP_KEY"
#define USE_LARGE_TITLES_ON_ROOT_LIST_NAME_KEY @"USE_LARGE_TITLES_ON_ROOT_LIST_NAME_KEY"
#define USE_LARGE_TITLES_ON_ROOT_LIST_GROUP_KEY @"USE_LARGE_TITLES_ON_ROOT_LIST_GROUP_KEY"
#define APP_SETTINGS_TITLE_NAME_KEY @"APP_SETTINGS_TITLE_NAME_KEY"
#define SOURCE_CODE_NAME_KEY @"SOURCE_CODE_NAME_KEY"
#define APP_VERSION_NAME_KEY @"APP_VERSION_NAME_KEY"

#define CHECK_FOR_UPDATES_TITLE_KEY @"CHECK_FOR_UPDATES_TITLE_KEY"
#define CHECK_FOR_UPDATES_ERROR_MESSAGE_KEY @"CHECK_FOR_UPDATES_ERROR_MESSAGE_KEY"
#define CHECK_FOR_UPDATES_PASS_MESSAGE_KEY @"CHECK_FOR_UPDATES_PASS_MESSAGE_KEY"
#define CHECK_FOR_UPDATES_FAIL_MESSAGE_KEY @"CHECK_FOR_UPDATES_FAIL_MESSAGE_KEY"

#endif //LOCALIZABLE_H
4 changes: 2 additions & 2 deletions TweakSettings-App/TS-Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ NS_INLINE __unused NSObject *OBJECT_WITH_PLIST_OPTIONS(NSString *path, NSPropert
NS_INLINE __unused NSDictionary *DICTIONARY_WITH_PLIST_OPTIONS(NSString *path, NSPropertyListReadOptions options) {
NSObject *object = OBJECT_WITH_PLIST_OPTIONS(path, options);
if (object && [object isKindOfClass:NSDictionary.class]) {
NSLog(@"ERROR (property-list file at %@ is not a dictionary)", path);
return (NSDictionary *) object;
}
NSLog(@"ERROR (property-list file at %@ is not a dictionary)", path);
return nil;
}

Expand All @@ -63,9 +63,9 @@ NS_INLINE __unused NSDictionary *DICTIONARY_WITH_PLIST(NSString *path) {
NS_INLINE __unused NSArray *ARRAY_WITH_PLIST_OPTIONS(NSString *path, NSPropertyListReadOptions options) {
NSObject *object = OBJECT_WITH_PLIST_OPTIONS(path, options);
if (object && [object isKindOfClass:NSArray.class]) {
NSLog(@"ERROR (property-list file at %@ is not an array)", path);
return (NSArray *) object;
}
NSLog(@"ERROR (property-list file at %@ is not an array)", path);
return nil;
}

Expand Down
13 changes: 12 additions & 1 deletion TweakSettings-App/TSAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@
#import <UIKit/UIKit.h>
#import "TSUtilityActionManager.h"

@class TSRootNavigationManager;

#define APP_DELEGATE ((TSAppDelegate *) UIApplication.sharedApplication.delegate)

@interface TSAppDelegate : UIApplication <UIApplicationDelegate>

@property(strong, nonatomic) UIWindow *window;
@property(nonatomic, weak) id popoverSender;
@property(nonatomic, strong, readonly) TSRootNavigationManager *navigationManager;

- (void)handleActionForType:(NSString *)actionType withConfirmationSender:(id)sender;
- (void)presentAsPopover:(UIViewController *)controller withSender:(id)sender;
- (void)presentViewController:(UIViewController *)controller;

- (void)handleActionForType:(NSString *)actionType;
- (void)openApplicationURL:(NSURL *)url;

- (void)generateURL;

@end
125 changes: 56 additions & 69 deletions TweakSettings-App/TSAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,24 @@
//
//

#import <Preferences/PSRootController.h>
#import "TSAppDelegate.h"
#import <CoreSpotlight/CoreSpotlight.h>
#import <dlfcn.h>
#import "TSAppDelegate.h"
#import "TSRootListController.h"
#import "Localizable.h"
#import "TSRootNavigationManager.h"
#import "TSUserDefaults.h"

void HandleExceptions(NSException *exception) {
NSLog(@"unhandled exception: %@", [exception debugDescription]);
}

@interface TSAppDelegate ()

@property(nonatomic, strong) PSRootController *rootController;
@property(nonatomic, strong) TSRootListController *rootListController;
@property(nonatomic, strong) NSString *launchIdentifier;

@end
static void HandleExceptions(NSException *exception) {
NSLog(@"TweakSettings unhandled exception: %@", exception.debugDescription);
}

@implementation TSAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
#pragma mark - UIApplicationDelegate

- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions {

NSSetUncaughtExceptionHandler(&HandleExceptions);

Expand All @@ -39,58 +34,40 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[[UIApplicationShortcutItem alloc] initWithType:TSActionTypeRespring localizedTitle:NSLocalizedString(RESPRING_TITLE_KEY, nil) localizedSubtitle:NSLocalizedString(RESPRING_SUBTITLE_KEY, nil) icon:nil userInfo:nil]
];

_rootListController = [TSRootListController new];
_rootController = [[PSRootController alloc] initWithRootViewController:_rootListController];
_rootListController.rootController = _rootController;
_rootListController.launchIdentifier = _launchIdentifier;
_navigationManager = [TSRootNavigationManager new];

self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
self.window.rootViewController = _rootController;
self.window.rootViewController = (id)_navigationManager.splitController;
[self.window makeKeyAndVisible];

if (launchOptions[UIApplicationLaunchOptionsShortcutItemKey]) {

[self handleActionForType:[(UIApplicationShortcutItem *)launchOptions[UIApplicationLaunchOptionsShortcutItemKey] type] withConfirmationSender:nil];
return NO;
}

return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
if (launchOptions[UIApplicationLaunchOptionsShortcutItemKey]) {

[self handleActionForType:[(UIApplicationShortcutItem *)launchOptions[UIApplicationLaunchOptionsShortcutItemKey] type]];
return NO;
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
if (launchOptions[UIApplicationLaunchOptionsURLKey]) {

[self.navigationManager.rootListController setShowOnLoad:NO];
[self.navigationManager setDeferredLoadURL:launchOptions[UIApplicationLaunchOptionsURLKey]];
return NO;
}

- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {

if ([url.scheme isEqualToString:@"tweaks"]) {

NSString *urlString = url.absoluteString;
if (self.navigationManager.rootListController.rootListLoaded) {

if ([urlString containsString:@"root="]) {
self.launchIdentifier = [urlString substringFromIndex:[urlString rangeOfString:@"root="].location + 5];
[self.navigationManager processURL:url animated:YES];
}

return YES;
Expand All @@ -101,50 +78,55 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(N

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {

[self handleActionForType:shortcutItem.type withConfirmationSender:nil];
[self handleActionForType:shortcutItem.type];
completionHandler(YES);
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> *))restorationHandler {

if ([userActivity.activityType isEqualToString:CSSearchableItemActionType]) {
self.launchIdentifier = [userActivity.userInfo[CSSearchableItemActivityIdentifier] stringByReplacingOccurrencesOfString:@"tweaks:root=" withString:@""];
NSURL *launchURL = [NSURL URLWithString:userActivity.userInfo[CSSearchableItemActivityIdentifier]];
[self.navigationManager processURL:launchURL animated:NO];
}

return YES;
}

- (void)handleActionForType:(NSString *)actionType withConfirmationSender:(id)sender {
#pragma mark - Public Methods

- (void)presentAsPopover:(UIViewController *)controller withSender:(id)sender {

if (sender == nil) sender = _navigationManager.rootListController.navigationItem.rightBarButtonItem;
self.popoverSender = sender;

UIAlertController *controller = ActionAlertForType(actionType);
controller.modalPresentationStyle = UIModalPresentationPopover;

if (sender && [sender isKindOfClass:UIBarButtonItem.class]) {

controller.popoverPresentationController.barButtonItem = sender;
}
else if (sender && [sender isKindOfClass:UIView.class]) {
controller.popoverPresentationController.sourceRect = [sender bounds];
controller.popoverPresentationController.sourceView = sender;
controller.popoverPresentationController.permittedArrowDirections = (UIPopoverArrowDirection)0;
}

} else if (sender && [sender isKindOfClass:UIView.class]) {

controller.popoverPresentationController.sourceView = (UIView *)sender;
controller.popoverPresentationController.sourceRect = ((UIView *)sender).bounds;
[_navigationManager.rootListController presentViewController:controller animated:YES completion:nil];
}

} else {
- (void)presentViewController:(UIViewController *)controller {
[_navigationManager.topNavigationController presentViewController:controller animated:YES completion:nil];
}

controller.popoverPresentationController.sourceView = self.rootController.view;
controller.popoverPresentationController.sourceRect = self.rootController.view.bounds;
}
- (void)handleActionForType:(NSString *)actionType {

[self.rootController presentViewController:controller animated:YES completion:nil];
}
if (CanRunWithoutConfirmation(actionType) && !TSUserDefaults.sharedDefaults.requireActionConfirmation) {

- (void)setLaunchIdentifier:(NSString *)launchIdentifier {
HandleActionForType(actionType);

_launchIdentifier = [launchIdentifier stringByReplacingOccurrencesOfString:@"tweaks:root=" withString:@""];
_launchIdentifier = launchIdentifier;
_rootListController.launchIdentifier = launchIdentifier;
} else {

[_rootController popToRootViewControllerAnimated:NO];
[_rootListController pushToLaunchIdentifier];
[self presentAsPopover:ActionAlertForType(actionType) withSender:_popoverSender];
}
}

- (void)openApplicationURL:(NSURL *)url {
Expand All @@ -157,4 +139,9 @@ - (void)openApplicationURL:(NSURL *)url {
}
}

- (void)generateURL {
NSURL *url = [self.navigationManager urlForCurrentNavStack];
[NSUserDefaults.standardUserDefaults setObject:url.absoluteString forKey:@"kPreferencePositionKey"];
}

@end
11 changes: 11 additions & 0 deletions TweakSettings-App/TSChangelogController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// Created by Dana Buehre on 11/21/21.
//

#import <Foundation/Foundation.h>
#import <Preferences/PSListController.h>


@interface TSChangelogController : PSListController

@end
Loading

0 comments on commit 3dd6925

Please sign in to comment.