Skip to content

Commit

Permalink
Added tweaksettings-utility
Browse files Browse the repository at this point in the history
Added action menu for running actions in the app
Added (LDRestart, Reboot, Userspace Reboot, Toggle Tweak Injection) actions
Added action confirmation and description alerts
Repackaged Preference headers into the framework
Prevent stripping debug symbols
  • Loading branch information
CreatureSurvive committed May 31, 2021
1 parent d716a67 commit 4063a21
Show file tree
Hide file tree
Showing 65 changed files with 883 additions and 540 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "PSTableCell.h"
#import <Preferences/PSTableCell.h>

@interface PSControlTableCell : PSTableCell

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "PSViewController.h"
#import <Preferences/PSViewController.h>

@class UIKeyboard, PSEditingPane, UIView;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This header is generated by classdump-dyld 1.0
* on Sunday, July 31, 2016 at 10:10:26 PM Australian Western Standard Time
* Operating System: Version 9.3.3 (Build 13G34)
* Image Source: /System/Library/PrivateFrameworks/Preferences.framework/Preferences
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/

#import <Preferences/PSListController.h>

@interface PSEditableListController : PSListController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "PSTableCell.h"
#import <Preferences/PSTableCell.h>

@class PSSpecifier;
@interface PSEditableTableCell : PSTableCell {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
/**
* @Author: Dana Buehre <creaturesurvive>
* @Date: 17-09-2016 2:51:39
* @Email: [email protected]
* @Project: motuumLS
* @Filename: PSListController.h
* @Last modified by: creaturesurvive
* @Last modified time: 08-07-2017 6:23:13
* @Copyright: Copyright © 2014-2017 CreatureSurvive
*/


#import "PSViewController.h"
#import <UIKit/UITableView.h>
#import <Preferences/PSViewController.h>

@class PSRootController, PSSpecifier, PSTableCell;

Expand Down Expand Up @@ -154,4 +143,5 @@
- (void)_keyboardDidShow:(id)sender;
- (void)_keyboardWillHide:(id)sender;
- (void)_keyboardDidHide:(id)sender;
- (void)_returnKeyPressed:(id)sender;
@end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "PSListController.h"
#import <Preferences/PSListController.h>

@class PSSpecifier;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#import <UIKit/UINavigationController.h>

@class PSListController;

@interface PSRootController : UINavigationController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "PSControlTableCell.h"
#import <Preferences/PSControlTableCell.h>

@interface PSSliderTableCell : PSControlTableCell

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "PSTableCell.h"
#import <Preferences/PSTableCell.h>
#include <sys/cdefs.h>

__BEGIN_DECLS
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "PSControlTableCell.h"
#import <Preferences/PSControlTableCell.h>

@class UIActivityIndicatorView;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#import <UIKit/UITableViewCell.h>

@class PSSpecifier;

typedef NS_ENUM(NSInteger, PSCellType) {
typedef enum : NSUInteger {
PSGroupCell,
PSLinkCell,
PSLinkListCell,
Expand All @@ -17,7 +19,7 @@ typedef NS_ENUM(NSInteger, PSCellType) {
PSButtonCell,
PSEditTextViewCell,
PSSpinnerCell
};
} PSCellType;

@interface PSTableCell : UITableViewCell

Expand Down
File renamed without changes.
755 changes: 346 additions & 409 deletions Frameworks/Preferences.framework/Preferences.tbd

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
export TARGET = iphone:clang:13.0:10.0
export ARCHS = armv7 arm64

DEBUG = 0
DEBUG = 1
FINALPACKAGE = 1
GO_EASY_ON_ME = 0
LEAN_AND_MEAN = 1
THEOS_PACKAGE_DIR = Releases
INSTALL_TARGET_PROCESSES = TweakSettings
PACKAGE_VERSION = $(THEOS_PACKAGE_BASE_VERSION)

include $(THEOS)/makefiles/common.mk

Expand All @@ -16,6 +17,10 @@ TweakSettings_CODESIGN_FLAGS = -SResources/entitlements.plist

include $(THEOS_MAKE_PATH)/xcodeproj.mk

SUBPROJECTS += TweakSettings-Utility

include $(THEOS_MAKE_PATH)/aggregate.mk

after-stage::
$(ECHO_NOTHING)rm -f $(THEOS_STAGING_DIR)/Applications/TweakSettings.app/Localizable.strings$(ECHO_END)

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions TweakSettings-App/Localizable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Localizable.h
// TweakSettings
//
// Created by Dana Buehre on 5/22/21.
//

#ifndef LOCALIZABLE_H
#define LOCALIZABLE_H

#define RESPRING_TITLE_KEY @"RESPRING_TITLE_KEY"
#define SAFEMODE_TITLE_KEY @"SAFEMODE_TITLE_KEY"
#define UICACHE_TITLE_KEY @"UICACHE_TITLE_KEY"
#define LDRESTART_TITLE_KEY @"LDRESTART_TITLE_KEY"
#define REBOOT_TITLE_KEY @"REBOOT_TITLE_KEY"
#define USREBOOT_TITLE_KEY @"USREBOOT_TITLE_KEY"
#define TWEAKINJECT_TITLE_KEY @"TWEAKINJECT_TITLE_KEY"

#define TWEAKINJECT_SUBTITLE_KEY @"TWEAKINJECT_SUBTITLE_KEY"
#define UICACHE_SUBTITLE_KEY @"UICACHE_SUBTITLE_KEY"
#define SAFEMODE_SUBTITLE_KEY @"SAFEMODE_SUBTITLE_KEY"
#define RESPRING_SUBTITLE_KEY @"RESPRING_SUBTITLE_KEY"
#define LDRESTART_SUBTITLE_KEY @"LDRESTART_SUBTITLE_KEY"
#define REBOOT_SUBTITLE_KEY @"REBOOT_SUBTITLE_KEY"
#define USREBOOT_SUBTITLE_KEY @"USREBOOT_SUBTITLE_KEY"

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

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

#endif //LOCALIZABLE_H
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
//

#import <UIKit/UIKit.h>

#import "TSUtilityActionManager.h"

@interface TSAppDelegate : UIApplication <UIApplicationDelegate>

@property(strong, nonatomic) UIWindow *window;

- (void)handleActionForType:(NSString *)actionType withConfirmationSender:(id)sender;

@end
37 changes: 21 additions & 16 deletions TweakSettings/TSAppDelegate.m → TweakSettings-App/TSAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//
//

#import <Preferences/PSRootController.h>
#import "TSAppDelegate.h"
#import "TSRootListController.h"
#import "PSRootController.h"
#import "Localizable.h"

void HandleExceptions(NSException *exception) {
Expand All @@ -19,7 +19,6 @@ @interface TSAppDelegate ()

@property(nonatomic, strong) PSRootController *rootController;
@property(nonatomic, strong) TSRootListController *rootListController;
@property(nonatomic, strong) NSDictionary *options;

@end

Expand All @@ -30,12 +29,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

NSSetUncaughtExceptionHandler(&HandleExceptions);

_options = DICTIONARY_WITH_PLIST(@"/Applications/TweakSettings.app/options.plist");

application.shortcutItems = @[
[[UIApplicationShortcutItem alloc] initWithType:@"respring" localizedTitle:NSLocalizedString(RESPRING_APPLICATION_TITLE, nil) localizedSubtitle:nil icon:nil userInfo:nil],
[[UIApplicationShortcutItem alloc] initWithType:@"safemode" localizedTitle:NSLocalizedString(SAFEMODE_APPLICATION_TITLE, nil) localizedSubtitle:nil icon:nil userInfo:nil],
[[UIApplicationShortcutItem alloc] initWithType:@"uicache" localizedTitle:NSLocalizedString(UICACHE_APPLICATION_TITLE, nil) localizedSubtitle:nil icon:nil userInfo:nil]
[[UIApplicationShortcutItem alloc] initWithType:TSActionTypeTweakInject localizedTitle:NSLocalizedString(TWEAKINJECT_TITLE_KEY, nil) localizedSubtitle:NSLocalizedString(TWEAKINJECT_SUBTITLE_KEY, nil) icon:nil userInfo:nil],
[[UIApplicationShortcutItem alloc] initWithType:TSActionTypeUICache localizedTitle:NSLocalizedString(UICACHE_TITLE_KEY, nil) localizedSubtitle:NSLocalizedString(UICACHE_SUBTITLE_KEY, nil) icon:nil userInfo:nil],
[[UIApplicationShortcutItem alloc] initWithType:TSActionTypeSafemode localizedTitle:NSLocalizedString(SAFEMODE_TITLE_KEY, nil) localizedSubtitle:NSLocalizedString(SAFEMODE_SUBTITLE_KEY, nil) icon:nil userInfo:nil],
[[UIApplicationShortcutItem alloc] initWithType:TSActionTypeRespring localizedTitle:NSLocalizedString(RESPRING_TITLE_KEY, nil) localizedSubtitle:NSLocalizedString(RESPRING_SUBTITLE_KEY, nil) icon:nil userInfo:nil]
];

_rootListController = [TSRootListController new];
Expand All @@ -47,7 +45,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

if (launchOptions[UIApplicationLaunchOptionsShortcutItemKey]) {

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

Expand Down Expand Up @@ -92,24 +90,31 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction

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

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

- (void)handleShortcutItemPressed:(UIApplicationShortcutItem *)item {
- (void)handleActionForType:(NSString *)actionType withConfirmationSender:(id)sender {

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

if ([item.type isEqualToString:@"respring"]) {
if (sender && [sender isKindOfClass:UIBarButtonItem.class]) {

STATUS_FOR_COMMAND(@"/usr/bin/killall backboardd");
controller.popoverPresentationController.barButtonItem = sender;

} else if ([item.type isEqualToString:@"safemode"]) {
} else if (sender && [sender isKindOfClass:UIView.class]) {

STATUS_FOR_COMMAND(@"/usr/bin/killall -SEGV SpringBoard");
controller.popoverPresentationController.sourceView = (UIView *)sender;
controller.popoverPresentationController.sourceRect = ((UIView *)sender).bounds;

} else if ([item.type isEqualToString:@"uicache"]) {
} else {

STATUS_FOR_COMMAND(@"/usr/bin/uicache");
controller.popoverPresentationController.sourceView = self.rootController.view;
controller.popoverPresentationController.sourceRect = self.rootController.view.bounds;
}

[self.rootController presentViewController:controller animated:YES completion:nil];
}

@end
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
//
//

#import <Preferences/PSSpecifier.h>
#import "TSRootListController.h"
#import "PSSpecifier.h"
#import "Localizable.h"
#import "libprefs.h"
#import "TSAppDelegate.h"

@interface TSRootListController ()

Expand All @@ -22,7 +23,12 @@ @implementation TSRootListController {
- (void)viewDidLoad {
[super viewDidLoad];

self.navigationItem.title = NSLocalizedString(ROOT_NAVIGATION_TITLE, nil);
self.navigationItem.title = NSLocalizedString(ROOT_NAVIGATION_TITLE_KEY, nil);
if (@available(iOS 14, *)) {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(ROOT_NAVIGATION_RIGHT_TITLE_KEY, nil) menu:ActionListMenu(self)];
} else {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(ROOT_NAVIGATION_RIGHT_TITLE_KEY, nil) style:UIBarButtonItemStylePlain target:self action:@selector(handleActionButtonTapped:)];
}

_refreshControl = [UIRefreshControl new];
[_refreshControl addTarget:self action:@selector(handleRefresh) forControlEvents:UIControlEventValueChanged];
Expand All @@ -33,8 +39,8 @@ - (NSMutableArray *)specifiers {
if (!_specifiers) {
NSMutableArray *specifiers = [self loadTweakSpecifiers].mutableCopy;

NSString *appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
NSString *footerText = [NSString stringWithFormat:@"Tweak Settings - v%@\nCreatureCoding © 2021", appVersion];
NSString *appVersion = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
NSString *footerText = [NSString stringWithFormat:@"Tweak Settings v%@\nCreatureCoding © 2021", appVersion];
PSSpecifier *groupSpecifier = [PSSpecifier emptyGroupSpecifier];
[groupSpecifier setProperty:footerText forKey:PSFooterTextGroupKey];
[groupSpecifier setProperty:@1 forKey:PSFooterAlignmentGroupKey];
Expand Down Expand Up @@ -99,4 +105,9 @@ - (void)handleRefresh {
[self reloadSpecifiers];
}

- (void)handleActionButtonTapped:(UIBarButtonItem *)sender {

[self.navigationController presentViewController:ActionListAlert(sender) animated:YES completion:nil];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//

#import <UIKit/UIKit.h>
#import "PSListController.h"
#import <Preferences/PSListController.h>

@class PSSpecifier;

@interface TSSearchableListController : PSListController <UISearchBarDelegate, UISearchResultsUpdating>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
//

#import <Preferences/PSSpecifier.h>
#import "TSSearchableListController.h"

@interface TSSearchableListController ()
Expand Down
30 changes: 30 additions & 0 deletions TweakSettings-App/TSUtilityActionManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// TSActionType.h
// TweakSettings
//
// Created by Dana Buehre on 5/30/21.
//
//

#ifndef TSActionType_h
#define TSActionType_h

@class UIAlertController;
@class UIAlertAction;

extern NSString *const TSActionTypeRespring;
extern NSString *const TSActionTypeSafemode;
extern NSString *const TSActionTypeUICache;
extern NSString *const TSActionTypeLDRestart;
extern NSString *const TSActionTypeReboot;
extern NSString *const TSActionTypeUserspaceReboot;
extern NSString *const TSActionTypeTweakInject;

extern inline NSString *TitleForActionType(NSString *type);
extern inline NSString *SubtitleForActionType(NSString *type);
extern inline int HandleActionForType(NSString *actionType);
extern inline UIAlertController *ActionAlertForType(NSString *actionType);
extern inline UIAlertController *ActionListAlert(id sender);
extern inline UIMenu *ActionListMenu(id sender) API_AVAILABLE(ios(13.0));

#endif /* TSActionType_h */
Loading

0 comments on commit 4063a21

Please sign in to comment.