summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2021-08-16 16:09:37 -0400
committerCameron Katri <me@cameronkatri.com>2021-08-16 16:10:54 -0400
commit615b0aefe92fb5d7b1fae821f91eb98e3f403bfe (patch)
treecc157ab8b0684f1b85b6645fe6198ae62dcbbe53
parent4d2aa96bbce1edc066b3bfc197d1e2e968e4aa5d (diff)
downloadtweaks-615b0aefe92fb5d7b1fae821f91eb98e3f403bfe.tar.gz
tweaks-615b0aefe92fb5d7b1fae821f91eb98e3f403bfe.tar.zst
tweaks-615b0aefe92fb5d7b1fae821f91eb98e3f403bfe.zip
QuickActions: Add new tweak
-rw-r--r--.gitignore1
-rw-r--r--QuickActions/Makefile18
-rw-r--r--QuickActions/QuickActions.plist7
-rw-r--r--QuickActions/QuickActionsPrefs/Makefile16
-rw-r--r--QuickActions/QuickActionsPrefs/QASRootListController.h4
-rw-r--r--QuickActions/QuickActionsPrefs/QASRootListController.m20
-rw-r--r--QuickActions/QuickActionsPrefs/Resources/Icon@2x.pngbin0 -> 4436 bytes
-rw-r--r--QuickActions/QuickActionsPrefs/Resources/Icon@3x.pngbin0 -> 8221 bytes
-rw-r--r--QuickActions/QuickActionsPrefs/Resources/Info.plist24
-rw-r--r--QuickActions/QuickActionsPrefs/Resources/Root.plist123
-rw-r--r--QuickActions/QuickActionsPrefs/layout/Library/PreferenceLoader/Preferences/QuickActionsPrefs.plist21
-rw-r--r--QuickActions/Resources/Banner.pngbin0 -> 1340288 bytes
-rw-r--r--QuickActions/Resources/Description.md8
-rw-r--r--QuickActions/Resources/Icon.pngbin0 -> 1855479 bytes
-rw-r--r--QuickActions/Resources/Screenshot-1.pngbin0 -> 1760816 bytes
-rw-r--r--QuickActions/Resources/Screenshot-2.pngbin0 -> 500352 bytes
-rw-r--r--QuickActions/Tweak.h62
-rw-r--r--QuickActions/Tweak.x116
-rw-r--r--QuickActions/control9
19 files changed, 429 insertions, 0 deletions
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 <Preferences/PSListController.h>
+
+@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 <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
index 0000000..307e3e3
--- /dev/null
+++ b/QuickActions/QuickActionsPrefs/Resources/Icon@2x.png
Binary files differ
diff --git a/QuickActions/QuickActionsPrefs/Resources/Icon@3x.png b/QuickActions/QuickActionsPrefs/Resources/Icon@3x.png
new file mode 100644
index 0000000..6c9a06b
--- /dev/null
+++ b/QuickActions/QuickActionsPrefs/Resources/Icon@3x.png
Binary files 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 @@
+<?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
index 0000000..5b0c436
--- /dev/null
+++ b/QuickActions/QuickActionsPrefs/Resources/Root.plist
@@ -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
index 0000000..baa738f
--- /dev/null
+++ b/QuickActions/QuickActionsPrefs/layout/Library/PreferenceLoader/Preferences/QuickActionsPrefs.plist
@@ -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
index 0000000..a868b1b
--- /dev/null
+++ b/QuickActions/Resources/Banner.png
Binary files 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
--- /dev/null
+++ b/QuickActions/Resources/Icon.png
Binary files differ
diff --git a/QuickActions/Resources/Screenshot-1.png b/QuickActions/Resources/Screenshot-1.png
new file mode 100644
index 0000000..1fd519a
--- /dev/null
+++ b/QuickActions/Resources/Screenshot-1.png
Binary files differ
diff --git a/QuickActions/Resources/Screenshot-2.png b/QuickActions/Resources/Screenshot-2.png
new file mode 100644
index 0000000..d678e2f
--- /dev/null
+++ b/QuickActions/Resources/Screenshot-2.png
Binary files 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 <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
index 0000000..61d6a65
--- /dev/null
+++ b/QuickActions/Tweak.x
@@ -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
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 <me@cameronkatri.com>
+Author: Cameron Katri <me@cameronkatri.com>
+Section: Tweaks
+Depends: com.opa334.altlist, mobilesubstrate (>= 0.9.5000)