]> git.cameronkatri.com Git - tweaks.git/commitdiff
QuickActions: Add new tweak
authorCameron Katri <me@cameronkatri.com>
Mon, 16 Aug 2021 20:09:37 +0000 (16:09 -0400)
committerCameron Katri <me@cameronkatri.com>
Mon, 16 Aug 2021 20:10:54 +0000 (16:10 -0400)
19 files changed:
.gitignore
QuickActions/Makefile [new file with mode: 0644]
QuickActions/QuickActions.plist [new file with mode: 0644]
QuickActions/QuickActionsPrefs/Makefile [new file with mode: 0644]
QuickActions/QuickActionsPrefs/QASRootListController.h [new file with mode: 0644]
QuickActions/QuickActionsPrefs/QASRootListController.m [new file with mode: 0644]
QuickActions/QuickActionsPrefs/Resources/Icon@2x.png [new file with mode: 0644]
QuickActions/QuickActionsPrefs/Resources/Icon@3x.png [new file with mode: 0644]
QuickActions/QuickActionsPrefs/Resources/Info.plist [new file with mode: 0644]
QuickActions/QuickActionsPrefs/Resources/Root.plist [new file with mode: 0644]
QuickActions/QuickActionsPrefs/layout/Library/PreferenceLoader/Preferences/QuickActionsPrefs.plist [new file with mode: 0644]
QuickActions/Resources/Banner.png [new file with mode: 0644]
QuickActions/Resources/Description.md [new file with mode: 0644]
QuickActions/Resources/Icon.png [new file with mode: 0644]
QuickActions/Resources/Screenshot-1.png [new file with mode: 0644]
QuickActions/Resources/Screenshot-2.png [new file with mode: 0644]
QuickActions/Tweak.h [new file with mode: 0644]
QuickActions/Tweak.x [new file with mode: 0644]
QuickActions/control [new file with mode: 0644]

index 446282ec7ca7b5fd2add20adb325045b64723991..18796dcdaa1f902b369544d80be34e57e56c1d19 100644 (file)
@@ -1,2 +1,3 @@
 .theos
 packages
+.DS_Store
diff --git a/QuickActions/Makefile b/QuickActions/Makefile
new file mode 100644 (file)
index 0000000..bec96ec
--- /dev/null
@@ -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 (file)
index 0000000..16b56e1
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       Filter = {
+               Bundles = (
+                       "com.apple.springboard"
+               );
+       };
+}
diff --git a/QuickActions/QuickActionsPrefs/Makefile b/QuickActions/QuickActionsPrefs/Makefile
new file mode 100644 (file)
index 0000000..df9918b
--- /dev/null
@@ -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 (file)
index 0000000..6b45016
--- /dev/null
@@ -0,0 +1,4 @@
+#import <Preferences/PSListController.h>
+
+@interface QASRootListController : PSListController 
+@end
diff --git a/QuickActions/QuickActionsPrefs/QASRootListController.m b/QuickActions/QuickActionsPrefs/QASRootListController.m
new file mode 100644 (file)
index 0000000..e781ab6
--- /dev/null
@@ -0,0 +1,20 @@
+#import <Foundation/Foundation.h>
+#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 (file)
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 (file)
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 (file)
index 0000000..afd9d3f
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>CFBundleDevelopmentRegion</key>
+       <string>English</string>
+       <key>CFBundleExecutable</key>
+       <string>QuickActionsPrefs</string>
+       <key>CFBundleIdentifier</key>
+       <string>com.cameronkatri.quickactions</string>
+       <key>CFBundleInfoDictionaryVersion</key>
+       <string>6.0</string>
+       <key>CFBundlePackageType</key>
+       <string>BNDL</string>
+       <key>CFBundleShortVersionString</key>
+       <string>1.0.0</string>
+       <key>CFBundleSignature</key>
+       <string>????</string>
+       <key>CFBundleVersion</key>
+       <string>1.0</string>
+       <key>NSPrincipalClass</key>
+       <string>QASRootListController</string>
+</dict>
+</plist>
diff --git a/QuickActions/QuickActionsPrefs/Resources/Root.plist b/QuickActions/QuickActionsPrefs/Resources/Root.plist
new file mode 100644 (file)
index 0000000..5b0c436
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>items</key>
+       <array>
+               <dict>
+                       <key>cell</key>
+                       <string>PSGroupCell</string>
+                       <key>label</key>
+                       <string>QuickActions</string>
+               </dict>
+               <dict>
+                       <key>cell</key>
+                       <string>PSSwitchCell</string>
+                       <key>defaults</key>
+                       <string>com.cameronkatri.quickactions</string>
+                       <key>key</key>
+                       <string>leftOn</string>
+                       <key>label</key>
+                       <string>Custom Left Button</string>
+                       <key>default</key>
+                       <false/>
+                       <key>PostNotification</key>
+                       <string>com.cameronkatri.quickactions/ReloadPrefs</string>
+               </dict>
+               <dict>
+                       <key>cell</key>
+                       <string>PSLinkListCell</string>
+                       <key>defaults</key>
+                       <string>com.cameronkatri.quickactions</string>
+                       <key>label</key>
+                       <string>Left App</string>
+                       <key>detail</key>
+                       <string>ATLApplicationListSelectionController</string>
+                       <key>key</key>
+                       <string>leftApp</string>
+                       <key>cellClass</key>
+                       <string>ATLApplicationSelectionCell</string>
+                       <key>sections</key>
+                       <array>
+                               <dict>
+                                       <key>sectionType</key>
+                                       <string>System</string>
+                               </dict>
+                               <dict>
+                                       <key>sectionType</key>
+                                       <string>User</string>
+                               </dict>
+                       </array>
+                       <key>useSearchBar</key>
+                       <true/>
+                       <key>hideSearchBarWhileScrolling</key>
+                       <false/>
+                       <key>showIdentifiersAsSubtitle</key>
+                       <true/>
+                       <key>includeIdentifiersInSearch</key>
+                       <true/>
+                       <key>PostNotification</key>
+                       <string>com.cameronkatri.quickactions/ReloadPrefs</string>
+               </dict>
+               <dict>
+                       <key>cell</key>
+                       <string>PSSwitchCell</string>
+                       <key>defaults</key>
+                       <string>com.cameronkatri.quickactions</string>
+                       <key>key</key>
+                       <string>rightOn</string>
+                       <key>label</key>
+                       <string>Custom Right Button</string>
+                       <key>default</key>
+                       <false/>
+                       <key>PostNotification</key>
+                       <string>com.cameronkatri.quickactions/ReloadPrefs</string>
+               </dict>
+               <dict>
+                       <key>cell</key>
+                       <string>PSLinkListCell</string>
+                       <key>defaults</key>
+                       <string>com.cameronkatri.quickactions</string>
+                       <key>label</key>
+                       <string>Right App</string>
+                       <key>detail</key>
+                       <string>ATLApplicationListSelectionController</string>
+                       <key>key</key>
+                       <string>rightApp</string>
+                       <key>cellClass</key>
+                       <string>ATLApplicationSelectionCell</string>
+                       <key>sections</key>
+                       <array>
+                               <dict>
+                                       <key>sectionType</key>
+                                       <string>System</string>
+                               </dict>
+                               <dict>
+                                       <key>sectionType</key>
+                                       <string>User</string>
+                               </dict>
+                       </array>
+                       <key>useSearchBar</key>
+                       <true/>
+                       <key>hideSearchBarWhileScrolling</key>
+                       <false/>
+                       <key>showIdentifiersAsSubtitle</key>
+                       <true/>
+                       <key>includeIdentifiersInSearch</key>
+                       <true/>
+                       <key>PostNotification</key>
+                       <string>com.cameronkatri.quickactions/ReloadPrefs</string>
+               </dict>
+               <dict>
+                       <key>cell</key>
+                       <string>PSButtonCell</string>
+                       <key>label</key>
+                       <string>Source Code</string>
+                       <key>action</key>
+                       <string>openSource</string>
+               </dict>
+       </array>
+       <key>title</key>
+       <string>QuickActions</string>
+</dict>
+</plist>
diff --git a/QuickActions/QuickActionsPrefs/layout/Library/PreferenceLoader/Preferences/QuickActionsPrefs.plist b/QuickActions/QuickActionsPrefs/layout/Library/PreferenceLoader/Preferences/QuickActionsPrefs.plist
new file mode 100644 (file)
index 0000000..baa738f
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>entry</key>
+       <dict>
+               <key>bundle</key>
+               <string>QuickActionsPrefs</string>
+               <key>cell</key>
+               <string>PSLinkCell</string>
+               <key>detail</key>
+               <string>QASRootListController</string>
+               <key>icon</key>
+               <string>Icon.png</string>
+               <key>isController</key>
+               <true/>
+               <key>label</key>
+               <string>QuickActions</string>
+       </dict>
+</dict>
+</plist>
diff --git a/QuickActions/Resources/Banner.png b/QuickActions/Resources/Banner.png
new file mode 100644 (file)
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 (file)
index 0000000..09a7f75
--- /dev/null
@@ -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 (file)
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 (file)
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 (file)
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 (file)
index 0000000..f2855db
--- /dev/null
@@ -0,0 +1,62 @@
+#import <UIKit/UIViewController.h>
+
+@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 (file)
index 0000000..61d6a65
--- /dev/null
@@ -0,0 +1,116 @@
+#import <Foundation/NSUserDefaults.h>
+
+#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 (file)
index 0000000..a721377
--- /dev/null
@@ -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 <me@cameronkatri.com>
+Author: Cameron Katri <me@cameronkatri.com>
+Section: Tweaks
+Depends: com.opa334.altlist, mobilesubstrate (>= 0.9.5000)