From 615b0aefe92fb5d7b1fae821f91eb98e3f403bfe Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Mon, 16 Aug 2021 16:09:37 -0400 Subject: QuickActions: Add new tweak --- .gitignore | 1 + QuickActions/Makefile | 18 +++ QuickActions/QuickActions.plist | 7 ++ QuickActions/QuickActionsPrefs/Makefile | 16 +++ .../QuickActionsPrefs/QASRootListController.h | 4 + .../QuickActionsPrefs/QASRootListController.m | 20 ++++ .../QuickActionsPrefs/Resources/Icon@2x.png | Bin 0 -> 4436 bytes .../QuickActionsPrefs/Resources/Icon@3x.png | Bin 0 -> 8221 bytes .../QuickActionsPrefs/Resources/Info.plist | 24 ++++ .../QuickActionsPrefs/Resources/Root.plist | 123 +++++++++++++++++++++ .../Preferences/QuickActionsPrefs.plist | 21 ++++ QuickActions/Resources/Banner.png | Bin 0 -> 1340288 bytes QuickActions/Resources/Description.md | 8 ++ QuickActions/Resources/Icon.png | Bin 0 -> 1855479 bytes QuickActions/Resources/Screenshot-1.png | Bin 0 -> 1760816 bytes QuickActions/Resources/Screenshot-2.png | Bin 0 -> 500352 bytes QuickActions/Tweak.h | 62 +++++++++++ QuickActions/Tweak.x | 116 +++++++++++++++++++ QuickActions/control | 9 ++ 19 files changed, 429 insertions(+) create mode 100644 QuickActions/Makefile create mode 100644 QuickActions/QuickActions.plist create mode 100644 QuickActions/QuickActionsPrefs/Makefile create mode 100644 QuickActions/QuickActionsPrefs/QASRootListController.h create mode 100644 QuickActions/QuickActionsPrefs/QASRootListController.m create mode 100644 QuickActions/QuickActionsPrefs/Resources/Icon@2x.png create mode 100644 QuickActions/QuickActionsPrefs/Resources/Icon@3x.png create mode 100644 QuickActions/QuickActionsPrefs/Resources/Info.plist create mode 100644 QuickActions/QuickActionsPrefs/Resources/Root.plist create mode 100644 QuickActions/QuickActionsPrefs/layout/Library/PreferenceLoader/Preferences/QuickActionsPrefs.plist create mode 100644 QuickActions/Resources/Banner.png create mode 100644 QuickActions/Resources/Description.md create mode 100644 QuickActions/Resources/Icon.png create mode 100644 QuickActions/Resources/Screenshot-1.png create mode 100644 QuickActions/Resources/Screenshot-2.png create mode 100644 QuickActions/Tweak.h create mode 100644 QuickActions/Tweak.x create mode 100644 QuickActions/control diff --git a/.gitignore b/.gitignore index 446282e..18796dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .theos packages +.DS_Store diff --git a/QuickActions/Makefile b/QuickActions/Makefile new file mode 100644 index 0000000..bec96ec --- /dev/null +++ b/QuickActions/Makefile @@ -0,0 +1,18 @@ +THEOS_DEVICE_IP = localhost +THEOS_DEVICE_PORT = 2222 + +TARGET := iphone:clang:14.4:13.0 +INSTALL_TARGET_PROCESSES = SpringBoard + +ARCHS := arm64 arm64e + +include $(THEOS)/makefiles/common.mk + +TWEAK_NAME = QuickActions + +QuickActions_FILES = Tweak.x +QuickActions_CFLAGS = -fobjc-arc + +include $(THEOS_MAKE_PATH)/tweak.mk +SUBPROJECTS += QuickActionsPrefs +include $(THEOS_MAKE_PATH)/aggregate.mk diff --git a/QuickActions/QuickActions.plist b/QuickActions/QuickActions.plist new file mode 100644 index 0000000..16b56e1 --- /dev/null +++ b/QuickActions/QuickActions.plist @@ -0,0 +1,7 @@ +{ + Filter = { + Bundles = ( + "com.apple.springboard" + ); + }; +} diff --git a/QuickActions/QuickActionsPrefs/Makefile b/QuickActions/QuickActionsPrefs/Makefile new file mode 100644 index 0000000..df9918b --- /dev/null +++ b/QuickActions/QuickActionsPrefs/Makefile @@ -0,0 +1,16 @@ +TARGET := iphone:clang:14.4:13.0 + +include $(THEOS)/makefiles/common.mk + +ARCHS := arm64 arm64e + +BUNDLE_NAME = QuickActionsPrefs + +QuickActionsPrefs_FILES = QASRootListController.m +QuickActionsPrefs_FRAMEWORKS = UIKit +QuickActionsPrefs_PRIVATE_FRAMEWORKS = Preferences +QuickActionsPrefs_EXTRA_FRAMEWORKS = AltList +QuickActionsPrefs_INSTALL_PATH = /Library/PreferenceBundles +QuickActionsPrefs_CFLAGS = -fobjc-arc + +include $(THEOS_MAKE_PATH)/bundle.mk diff --git a/QuickActions/QuickActionsPrefs/QASRootListController.h b/QuickActions/QuickActionsPrefs/QASRootListController.h new file mode 100644 index 0000000..6b45016 --- /dev/null +++ b/QuickActions/QuickActionsPrefs/QASRootListController.h @@ -0,0 +1,4 @@ +#import + +@interface QASRootListController : PSListController +@end diff --git a/QuickActions/QuickActionsPrefs/QASRootListController.m b/QuickActions/QuickActionsPrefs/QASRootListController.m new file mode 100644 index 0000000..e781ab6 --- /dev/null +++ b/QuickActions/QuickActionsPrefs/QASRootListController.m @@ -0,0 +1,20 @@ +#import +#import "QASRootListController.h" + +@implementation QASRootListController + +-(NSArray *)specifiers +{ + if (!_specifiers) { + _specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self]; + } + + return _specifiers; +} + +-(void)openSource +{ + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://git.cameronkatri.com/tweaks/tree/QuickActions"] options:@{} completionHandler:nil]; +} + +@end diff --git a/QuickActions/QuickActionsPrefs/Resources/Icon@2x.png b/QuickActions/QuickActionsPrefs/Resources/Icon@2x.png new file mode 100644 index 0000000..307e3e3 Binary files /dev/null and b/QuickActions/QuickActionsPrefs/Resources/Icon@2x.png differ diff --git a/QuickActions/QuickActionsPrefs/Resources/Icon@3x.png b/QuickActions/QuickActionsPrefs/Resources/Icon@3x.png new file mode 100644 index 0000000..6c9a06b Binary files /dev/null and b/QuickActions/QuickActionsPrefs/Resources/Icon@3x.png differ diff --git a/QuickActions/QuickActionsPrefs/Resources/Info.plist b/QuickActions/QuickActionsPrefs/Resources/Info.plist new file mode 100644 index 0000000..afd9d3f --- /dev/null +++ b/QuickActions/QuickActionsPrefs/Resources/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + QuickActionsPrefs + CFBundleIdentifier + com.cameronkatri.quickactions + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSPrincipalClass + QASRootListController + + diff --git a/QuickActions/QuickActionsPrefs/Resources/Root.plist b/QuickActions/QuickActionsPrefs/Resources/Root.plist new file mode 100644 index 0000000..5b0c436 --- /dev/null +++ b/QuickActions/QuickActionsPrefs/Resources/Root.plist @@ -0,0 +1,123 @@ + + + + + items + + + cell + PSGroupCell + label + QuickActions + + + cell + PSSwitchCell + defaults + com.cameronkatri.quickactions + key + leftOn + label + Custom Left Button + default + + PostNotification + com.cameronkatri.quickactions/ReloadPrefs + + + cell + PSLinkListCell + defaults + com.cameronkatri.quickactions + label + Left App + detail + ATLApplicationListSelectionController + key + leftApp + cellClass + ATLApplicationSelectionCell + sections + + + sectionType + System + + + sectionType + User + + + useSearchBar + + hideSearchBarWhileScrolling + + showIdentifiersAsSubtitle + + includeIdentifiersInSearch + + PostNotification + com.cameronkatri.quickactions/ReloadPrefs + + + cell + PSSwitchCell + defaults + com.cameronkatri.quickactions + key + rightOn + label + Custom Right Button + default + + PostNotification + com.cameronkatri.quickactions/ReloadPrefs + + + cell + PSLinkListCell + defaults + com.cameronkatri.quickactions + label + Right App + detail + ATLApplicationListSelectionController + key + rightApp + cellClass + ATLApplicationSelectionCell + sections + + + sectionType + System + + + sectionType + User + + + useSearchBar + + hideSearchBarWhileScrolling + + showIdentifiersAsSubtitle + + includeIdentifiersInSearch + + PostNotification + com.cameronkatri.quickactions/ReloadPrefs + + + cell + PSButtonCell + label + Source Code + action + openSource + + + title + QuickActions + + diff --git a/QuickActions/QuickActionsPrefs/layout/Library/PreferenceLoader/Preferences/QuickActionsPrefs.plist b/QuickActions/QuickActionsPrefs/layout/Library/PreferenceLoader/Preferences/QuickActionsPrefs.plist new file mode 100644 index 0000000..baa738f --- /dev/null +++ b/QuickActions/QuickActionsPrefs/layout/Library/PreferenceLoader/Preferences/QuickActionsPrefs.plist @@ -0,0 +1,21 @@ + + + + + entry + + bundle + QuickActionsPrefs + cell + PSLinkCell + detail + QASRootListController + icon + Icon.png + isController + + label + QuickActions + + + diff --git a/QuickActions/Resources/Banner.png b/QuickActions/Resources/Banner.png new file mode 100644 index 0000000..a868b1b Binary files /dev/null and b/QuickActions/Resources/Banner.png differ diff --git a/QuickActions/Resources/Description.md b/QuickActions/Resources/Description.md new file mode 100644 index 0000000..09a7f75 --- /dev/null +++ b/QuickActions/Resources/Description.md @@ -0,0 +1,8 @@ +# QuickActions +Start using your phone quicker by launching your favorite apps directly from the lockscreen. + +## Settings +QuickActions depends on [AltList](https://moreinfo.thebigboss.org/moreinfo/depiction.php?file=altlistDp) to provide an easy way to select the apps you need at your fingertips. Whether you want to replace one or both buttons, QuickActions allows it, and it all applies without a respring. + +## Free Software +QuickActions is open source available under the FreeBSD license (BSD-2-Clause) [located at this repo](https://git.cameronkatri.com/tweaks/tree/QuickActions). diff --git a/QuickActions/Resources/Icon.png b/QuickActions/Resources/Icon.png new file mode 100644 index 0000000..e99c3cd Binary files /dev/null and b/QuickActions/Resources/Icon.png differ diff --git a/QuickActions/Resources/Screenshot-1.png b/QuickActions/Resources/Screenshot-1.png new file mode 100644 index 0000000..1fd519a Binary files /dev/null and b/QuickActions/Resources/Screenshot-1.png differ diff --git a/QuickActions/Resources/Screenshot-2.png b/QuickActions/Resources/Screenshot-2.png new file mode 100644 index 0000000..d678e2f Binary files /dev/null and b/QuickActions/Resources/Screenshot-2.png differ diff --git a/QuickActions/Tweak.h b/QuickActions/Tweak.h new file mode 100644 index 0000000..f2855db --- /dev/null +++ b/QuickActions/Tweak.h @@ -0,0 +1,62 @@ +#import + +@interface UIImage (Private) ++ (instancetype)_applicationIconImageForBundleIdentifier:(NSString*)bundleIdentifier format:(int)format scale:(CGFloat)scale; +@end + +@interface SBLeafIcon : NSObject +-(id)initWithLeafIdentifier:(id)arg1 applicationBundleID:(id)arg2 ; +@end + +@interface SBMainWorkspace : NSObject ++(id)sharedInstance; +-(void)systemService:(id)arg1 handleOpenApplicationRequest:(id)arg2 withCompletion:(/*^block*/id)arg3; +@end + +@interface FBProcess : NSObject +@end + +@interface FBProcessManager : NSObject +@property (nonatomic,readonly) id systemApplicationProcess; +-(id)systemApplicationProcess; ++(id)sharedInstance; +@end + +@interface FBSOpenApplicationOptions : NSObject ++(id)optionsWithDictionary:(id)arg1; +@end + +@interface FBSystemServiceOpenApplicationRequest : NSObject +@property (assign,getter=isTrusted,nonatomic) BOOL trusted; +@property (nonatomic,copy) NSString * bundleIdentifier; +@property (nonatomic,copy) FBSOpenApplicationOptions * options; +@property (nonatomic,retain) FBProcess * clientProcess; ++(id)request; +@end + +@interface CSQuickActionsButton : UIView { + UIImageView* _contentView; +} +@property (assign,nonatomic) long long type; +-(id)initWithType:(long long)type; +-(void)setImage:(UIImage *)arg1; +-(void)setSelected:(BOOL)arg; +-(UIImage *)image; +-(UIImage *)selectedImage; + +@property (nonatomic,retain) UIImage *originalImage; +-(void)loadImage; +@end + +@interface CSQuickActionsView : NSObject +@property (nonatomic,retain) CSQuickActionsButton * flashlightButton; +@property (nonatomic,retain) CSQuickActionsButton * cameraButton; +-(void)handleButtonTouchEnded:(id)button; +-(void)handleButtonTouchBegan:(id)button; +-(void)handleButtonPress:(id)button; +@end + +@interface NSUserDefaults (Private) +-(id)objectForKey:(NSString *)key inDomain:(NSString *)domain; +-(void)setObject:(id)value forKey:(NSString *)key inDomain:(NSString *)domain; +@end diff --git a/QuickActions/Tweak.x b/QuickActions/Tweak.x new file mode 100644 index 0000000..61d6a65 --- /dev/null +++ b/QuickActions/Tweak.x @@ -0,0 +1,116 @@ +#import + +#import "Tweak.h" + +static bool leftOn; +static NSString *leftApp; +static bool rightOn; +static NSString *rightApp; + +void openApplication(NSString *bundleID) +{ + FBSOpenApplicationOptions* opts = [%c(FBSOpenApplicationOptions) optionsWithDictionary:@{ + @"__LaunchOrigin" : @"BulletinDestinationCoverSheet", + @"__PromptUnlockDevice" : @YES, + @"__UnlockDevice" : @YES, + @"__LaunchImage" : @"", + @"__Actions" : @[] + }]; + FBSystemServiceOpenApplicationRequest* request = [%c(FBSystemServiceOpenApplicationRequest) request]; + request.options = opts; + request.bundleIdentifier = bundleID; + request.trusted = YES; + request.clientProcess = [[%c(FBProcessManager) sharedInstance] systemApplicationProcess]; + + [[%c(SBMainWorkspace) sharedInstance] systemService:[%c(FBSystemService) sharedInstance] handleOpenApplicationRequest:request withCompletion:^{}]; +} + +%hook CSQuickActionsView + +-(void)handleButtonPress:(CSQuickActionsButton *)button +{ + [button setSelected:false]; + if (leftOn && button.type == 1) + openApplication(leftApp); + else if (rightOn && button.type == 0) + openApplication(rightApp); + else + %orig; + return; +} + +-(void)handleButtonTouchBegan:(CSQuickActionsButton *)button +{ + if ((leftOn && button.type == 1) || + (rightOn && button.type == 0)) + return; + else + %orig; +} + +-(void)handleButtonTouchEnded:(CSQuickActionsButton *)button +{ + if ((leftOn && button.type == 1) || + (rightOn && button.type == 0)) + return; + else + %orig; +} + +%end + +%hook CSQuickActionsButton + +%property (nonatomic, retain) UIImage *originalImage; + +-(id)initWithType:(long long)type +{ + id o = %orig; + if (!self.originalImage) + self.originalImage = [self image]; + [self loadImage]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadImage) name:@"com.cameronkatri.quickactions/ReloadImages" object:nil]; + return o; +} + +-(void)setImage:(UIImage *)img +{ + %orig; + [[self valueForKey:@"_contentView"] setImage:img]; +} + +%new +-(void)loadImage +{ + if (self.type == 1 && leftOn) + [self setImage:[UIImage _applicationIconImageForBundleIdentifier:leftApp format:0 scale:[UIScreen mainScreen].scale]]; + else if (self.type == 0 && rightOn) + [self setImage:[UIImage _applicationIconImageForBundleIdentifier:rightApp format:0 scale:[UIScreen mainScreen].scale]]; + else + [self setImage:self.originalImage]; +} + +%end + +static void updatePrefs(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userinfo) +{ + NSNumber *leftOnValue = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"leftOn" inDomain:@"com.cameronkatri.quickactions"]; + NSNumber *rightOnValue = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"rightOn" inDomain:@"com.cameronkatri.quickactions"]; + leftApp = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:@"leftApp" inDomain:@"com.cameronkatri.quickactions"]; + rightApp = (NSString *)[[NSUserDefaults standardUserDefaults] objectForKey:@"rightApp" inDomain:@"com.cameronkatri.quickactions"]; + leftOn = leftOnValue ? [leftOnValue boolValue] : false; + rightOn = leftOnValue ? [rightOnValue boolValue] : false; + if ([leftApp isEqual:@""] || [leftApp length] == 0) + leftOn = false; + if ([rightApp isEqual:@""] || [rightApp length] == 0) + rightOn = false; + [[NSNotificationCenter defaultCenter] postNotificationName:@"com.cameronkatri.quickactions/ReloadImages" object:nil]; +} + +%ctor +{ + updatePrefs(NULL, NULL, NULL, NULL, NULL); + CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, updatePrefs, (CFStringRef)@"com.cameronkatri.quickactions/ReloadPrefs", NULL, CFNotificationSuspensionBehaviorCoalesce); +} + +// vim: filetype=logos diff --git a/QuickActions/control b/QuickActions/control new file mode 100644 index 0000000..a721377 --- /dev/null +++ b/QuickActions/control @@ -0,0 +1,9 @@ +Package: com.cameronkatri.quickactions +Name: QuickActions +Version: 1.0.0 +Architecture: iphoneos-arm +Description: Quickly launch apps from the lockscreen +Maintainer: Cameron Katri +Author: Cameron Katri +Section: Tweaks +Depends: com.opa334.altlist, mobilesubstrate (>= 0.9.5000) -- cgit v1.2.3-56-ge451