├── .gitignore ├── Common.h ├── CustomLockscreenDuration.plist ├── LICENSE ├── Makefile ├── README.md ├── Tweak.xm ├── control ├── flipswitch ├── FSSwitchDataSource.h ├── FSSwitchPanel.h ├── FSSwitchState.h ├── Makefile ├── Resources │ ├── Info.plist │ └── glyph.pdf └── Switch.m └── preferences ├── CLDPrefsRootListController.m ├── Makefile ├── Resources ├── Info.plist ├── Root.plist ├── donate.png ├── donate@2x.png ├── github.png ├── github@2x.png ├── icon.png ├── icon@2x.png ├── mail.png └── mail@2x.png └── entry.plist /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | .DS_Store 24 | .theos/ 25 | packages/ 26 | .cydiaRepoUpload.log 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | *.dSYM.zip 32 | *.dSYM 33 | 34 | # CocoaPods 35 | # 36 | # We recommend against adding the Pods directory to your .gitignore. However 37 | # you should judge for yourself, the pros and cons are mentioned at: 38 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 39 | # 40 | # Pods/ 41 | 42 | # Carthage 43 | # 44 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 45 | # Carthage/Checkouts 46 | 47 | Carthage/Build 48 | 49 | # fastlane 50 | # 51 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 52 | # screenshots whenever they are needed. 53 | # For more information about the recommended setup visit: 54 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 55 | 56 | fastlane/report.xml 57 | fastlane/screenshots 58 | 59 | #Code Injection 60 | # 61 | # After new code Injection tools there's a generated folder /iOSInjectionProject 62 | # https://github.com/johnno1962/injectionforxcode 63 | 64 | iOSInjectionProject/ 65 | -------------------------------------------------------------------------------- /Common.h: -------------------------------------------------------------------------------- 1 | #define kFlipswitchNotification "se.nosskirneh.customlockscreenduration.FSchanged" 2 | #define kPrefsChangedNotification "se.nosskirneh.customlockscreenduration/preferencesChanged" 3 | #define kPrefPath @"/var/mobile/Library/Preferences/se.nosskirneh.customlockduration.plist" 4 | -------------------------------------------------------------------------------- /CustomLockscreenDuration.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.springboard" ); }; } 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Andreas Henriksson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TARGET = iphone:clang:9.2 2 | ARCHS = armv7s arm64 arm64e 3 | 4 | include $(THEOS)/makefiles/common.mk 5 | 6 | TWEAK_NAME = CustomLockscreenDuration 7 | $(TWEAK_NAME)_FILES = Tweak.xm 8 | $(TWEAK_NAME)_CFLAGS = -fobjc-arc 9 | 10 | include $(THEOS_MAKE_PATH)/tweak.mk 11 | 12 | after-install:: 13 | install.exec "killall -9 Preferences" 14 | 15 | SUBPROJECTS += preferences 16 | SUBPROJECTS += flipswitch 17 | include $(THEOS_MAKE_PATH)/aggregate.mk 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CustomLockscreenDuration 2 | Compatible with 10, 11, 12 and 13. 3 | 4 | Customize the duration before going to sleep on lockscreen. 5 | -------------------------------------------------------------------------------- /Tweak.xm: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Common.h" 3 | 4 | 5 | static BOOL enabled; 6 | static long long duration; 7 | static BOOL chargeMode; 8 | static long long chargingDuration; 9 | 10 | static void reloadPrefs() { 11 | NSMutableDictionary *defaults = [NSMutableDictionary dictionary]; 12 | [defaults addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:kPrefPath]]; 13 | enabled = [defaults[@"enabled"] boolValue]; 14 | duration = [defaults[@"duration"] integerValue]; 15 | chargeMode = [defaults[@"chargeMode"] boolValue]; 16 | chargingDuration = [defaults[@"chargingDuration"] integerValue]; 17 | } 18 | 19 | void updateSettings(CFNotificationCenterRef center, 20 | void *observer, 21 | CFStringRef name, 22 | const void *object, 23 | CFDictionaryRef userInfo) { 24 | reloadPrefs(); 25 | } 26 | 27 | %hook BehaviorClass 28 | 29 | - (void)setIdleTimerDuration:(long long)arg { 30 | if (enabled) { 31 | BOOL charging = [[%c(SBUIController) sharedInstance] isBatteryCharging]; 32 | return %orig((chargeMode && charging) ? chargingDuration : duration); 33 | } 34 | 35 | %orig(arg); 36 | } 37 | 38 | %end 39 | 40 | %group iOS10 41 | %hook SBDashBoardIdleTimerEventPublisher 42 | 43 | - (BOOL)isEnabled { 44 | BOOL charging = [[%c(SBUIController) sharedInstance] isBatteryCharging]; 45 | BOOL infite = ((chargeMode && charging && chargingDuration == 0) || 46 | (!chargeMode && duration == 0)); 47 | return enabled && infite ? NO : %orig; 48 | } 49 | 50 | %end 51 | %end 52 | 53 | %group iOS11 54 | %hook SBDashBoardIdleTimerProvider 55 | 56 | - (BOOL)isIdleTimerEnabled { 57 | BOOL charging = [[%c(SBUIController) sharedInstance] isBatteryCharging]; 58 | BOOL infite = ((chargeMode && charging && chargingDuration == 0) || 59 | (!chargeMode && duration == 0)); 60 | return enabled && infite ? NO : %orig; 61 | } 62 | 63 | %end 64 | %end 65 | 66 | 67 | @interface CSBehavior : NSObject 68 | @end 69 | 70 | @interface SBDashBoardBehavior : NSObject 71 | @end 72 | 73 | %ctor { 74 | reloadPrefs(); 75 | CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &updateSettings, CFSTR(kPrefsChangedNotification), NULL, 0); 76 | CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &updateSettings, CFSTR(kFlipswitchNotification), NULL, 0); 77 | 78 | Class behaviorClass = %c(CSBehavior) ? : %c(SBDashBoardBehavior); 79 | %init(BehaviorClass = behaviorClass); 80 | if (%c(SBDashBoardIdleTimerEventPublisher)) 81 | %init(iOS10); 82 | else if (%c(SBDashBoardIdleTimerProvider)) 83 | %init(iOS11) 84 | } 85 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: se.nosskirneh.customlockscreenduration 2 | Name: CustomLockscreenDuration 3 | Version: 1.5 4 | Description: Customize the duration before going to sleep on lockscreen 5 | Depiction: https://andreashenriksson.se/repo/depictions/?p=se.nosskirneh.customlockscreenduration 6 | Depends: mobilesubstrate (>= 0.9.5000) 7 | Architecture: iphoneos-arm 8 | Maintainer: Andreas Henriksson 9 | Author: Andreas Henriksson 10 | Section: Tweaks 11 | -------------------------------------------------------------------------------- /flipswitch/FSSwitchDataSource.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "FSSwitchState.h" 3 | 4 | @protocol FSSwitchDataSource 5 | @optional 6 | 7 | - (FSSwitchState)stateForSwitchIdentifier:(NSString *)switchIdentifier; 8 | // Gets the current state of the switch. 9 | // Must override if building a settings-like switch. 10 | // Return FSSwitchStateIndeterminate if switch is loading 11 | // By default returns FSSwitchStateIndeterminate 12 | 13 | - (void)applyState:(FSSwitchState)newState forSwitchIdentifier:(NSString *)switchIdentifier; 14 | // Sets the new state of the switch 15 | // Must override if building a settings-like switch. 16 | // By default calls through to applyActionForSwitchIdentifier: if newState is different from the current state 17 | 18 | - (void)applyActionForSwitchIdentifier:(NSString *)switchIdentifier; 19 | // Runs the default action for the switch. 20 | // Must override if building an action-like switch. 21 | // By default calls through to applyState:forSwitchIdentifier: if state is not indeterminate 22 | 23 | - (NSString *)titleForSwitchIdentifier:(NSString *)switchIdentifier; 24 | // Returns the localized title for the switch. 25 | // By default reads the CFBundleDisplayName out of the switch's bundle. 26 | 27 | - (BOOL)shouldShowSwitchIdentifier:(NSString *)switchIdentifier; 28 | // Returns wether the switch should be shown. 29 | // By default returns YES or the value from GraphicsServices for the capability specified in the "required-capability-key" of the switch's bundle 30 | // E.g. You would detect if the device has the required capability (3G, flash etc) 31 | 32 | - (id)glyphImageDescriptorOfState:(FSSwitchState)switchState size:(CGFloat)size scale:(CGFloat)scale forSwitchIdentifier:(NSString *)switchIdentifier; 33 | // Provide an image descriptor that best displays at the requested size and scale 34 | // By default looks through the bundle to find a glyph image 35 | 36 | - (NSBundle *)bundleForSwitchIdentifier:(NSString *)switchIdentifier; 37 | // Provides a bundle to look for localizations/images in 38 | // By default returns the bundle for the current class 39 | 40 | - (void)switchWasRegisteredForIdentifier:(NSString *)switchIdentifier; 41 | // Called when switch is first registered 42 | 43 | - (void)switchWasUnregisteredForIdentifier:(NSString *)switchIdentifier; 44 | // Called when switch is unregistered 45 | 46 | - (BOOL)hasAlternateActionForSwitchIdentifier:(NSString *)switchIdentifier; 47 | // Gets whether the switch supports an alternate or "hold" action 48 | // By default queries if switch responds to applyAlternateActionForSwitchIdentifier: or if it has a "alternate-action-url" key set 49 | 50 | - (void)applyAlternateActionForSwitchIdentifier:(NSString *)switchIdentifier; 51 | // Applies the alternate or "hold" action 52 | // By default launches the URL stored in the "alternate-action-url" key of the switch's bundle 53 | 54 | @end -------------------------------------------------------------------------------- /flipswitch/FSSwitchPanel.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "FSSwitchState.h" 3 | 4 | @interface FSSwitchPanel : NSObject 5 | 6 | + (FSSwitchPanel *)sharedPanel; 7 | 8 | @property (nonatomic, readonly, copy) NSArray *switchIdentifiers; 9 | // Returns a list of identifying all switches installed on the device 10 | 11 | - (NSString *)titleForSwitchIdentifier:(NSString *)switchIdentifier; 12 | // Returns the localized title for a specific switch 13 | 14 | - (UIButton *)buttonForSwitchIdentifier:(NSString *)switchIdentifier usingTemplate:(NSBundle *)templateBundle; 15 | // Returns a UIButton for a specific switch 16 | // The button automatically updates its style based on the user interaction and switch state changes, applies the standard action when pressed, and applies the alternate action when held 17 | 18 | - (UIImage *)imageOfSwitchState:(FSSwitchState)state controlState:(UIControlState)controlState forSwitchIdentifier:(NSString *)switchIdentifier usingTemplate:(NSBundle *)templateBundle; 19 | - (UIImage *)imageOfSwitchState:(FSSwitchState)state controlState:(UIControlState)controlState scale:(CGFloat)scale forSwitchIdentifier:(NSString *)switchIdentifier usingTemplate:(NSBundle *)templateBundle; 20 | // Returns an image representing how a specific switch would look in a particular state when styled with the provided template 21 | 22 | - (id)glyphImageDescriptorOfState:(FSSwitchState)switchState size:(CGFloat)size scale:(CGFloat)scale forSwitchIdentifier:(NSString *)switchIdentifier; 23 | // Returns the raw glyph identifier as retrieved from the backing FSSwitch instance 24 | 25 | - (FSSwitchState)stateForSwitchIdentifier:(NSString *)switchIdentifier; 26 | // Returns the current state of a particualr switch 27 | - (void)setState:(FSSwitchState)state forSwitchIdentifier:(NSString *)switchIdentifier; 28 | // Updates the state of a particular switch. If the switch accepts the change it will send a state change 29 | - (void)applyActionForSwitchIdentifier:(NSString *)switchIdentifier; 30 | // Applies the default action of a particular switch 31 | 32 | - (BOOL)hasAlternateActionForSwitchIdentifier:(NSString *)switchIdentifier; 33 | // Queries whether a switch supports an alternate action. This is often triggered by a hold gesture 34 | - (void)applyAlternateActionForSwitchIdentifier:(NSString *)switchIdentifier; 35 | // Apply the alternate action of a particular switch 36 | 37 | - (void)openURLAsAlternateAction:(NSURL *)url; 38 | // Helper method to open a particular URL as if it were launched from an alternate action 39 | 40 | @end 41 | 42 | @protocol FSSwitchDataSource; 43 | 44 | @interface FSSwitchPanel (SpringBoard) 45 | - (void)registerDataSource:(id)dataSource forSwitchIdentifier:(NSString *)switchIdentifier; 46 | // Registers a switch implementation for a specific identifier. Bundlee in /Library/Switches will have their principal class automatically loaded 47 | - (void)unregisterSwitchIdentifier:(NSString *)switchIdentifier; 48 | // Unregisters a switch 49 | - (void)stateDidChangeForSwitchIdentifier:(NSString *)switchIdentifier; 50 | // Informs the system when a switch changes its state. This will trigger any switch buttons to update their style 51 | @end 52 | 53 | extern NSString * const FSSwitchPanelSwitchesChangedNotification; 54 | 55 | extern NSString * const FSSwitchPanelSwitchStateChangedNotification; 56 | extern NSString * const FSSwitchPanelSwitchIdentifierKey; 57 | 58 | extern NSString * const FSSwitchPanelSwitchWillOpenURLNotification; 59 | -------------------------------------------------------------------------------- /flipswitch/FSSwitchState.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | typedef enum { 4 | FSSwitchStateOff = 0, 5 | FSSwitchStateOn = 1, 6 | FSSwitchStateIndeterminate = -1 7 | } FSSwitchState; 8 | 9 | extern NSString *NSStringFromFSSwitchState(FSSwitchState state); 10 | extern FSSwitchState FSSwitchStateFromNSString(NSString *stateString); 11 | -------------------------------------------------------------------------------- /flipswitch/Makefile: -------------------------------------------------------------------------------- 1 | include $(THEOS)/makefiles/common.mk 2 | ARCHS = armv7s arm64 arm64e 3 | 4 | BUNDLE_NAME = CLDSwitch 5 | $(BUNDLE_NAME)_FILES = Switch.m 6 | $(BUNDLE_NAME)_CFLAGS = -fobjc-arc 7 | $(BUNDLE_NAME)_FRAMEWORKS = UIKit 8 | $(BUNDLE_NAME)_LIBRARIES = flipswitch 9 | $(BUNDLE_NAME)_INSTALL_PATH = /Library/Switches 10 | 11 | include $(THEOS_MAKE_PATH)/bundle.mk 12 | 13 | after-install:: 14 | install.exec "killall -9 SpringBoard" 15 | -------------------------------------------------------------------------------- /flipswitch/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | CustomLockDuration 9 | CFBundleIdentifier 10 | se.nosskirneh.cldswitch 11 | CFBundleDisplayName 12 | CustomLockDuration 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | DTPlatformName 24 | iphoneos 25 | MinimumOSVersion 26 | 3.0 27 | NSPrincipalClass 28 | CustomLockDurationSwitch 29 | alternate-action-url 30 | prefs: 31 | 32 | 33 | -------------------------------------------------------------------------------- /flipswitch/Resources/glyph.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nosskirneh/CustomLockscreenDuration/cf02198d24ef444063eeb8bd95830895e4420240/flipswitch/Resources/glyph.pdf -------------------------------------------------------------------------------- /flipswitch/Switch.m: -------------------------------------------------------------------------------- 1 | #import "FSSwitchDataSource.h" 2 | #import "FSSwitchPanel.h" 3 | #import "../Common.h" 4 | #import 5 | 6 | @interface CustomLockscreenDurationSwitch : NSObject 7 | @end 8 | 9 | @implementation CustomLockscreenDurationSwitch 10 | 11 | - (NSString *)titleForSwitchIdentifier:(NSString *)switchIdentifier { 12 | return @"Custom Lockscreen Duration"; 13 | } 14 | 15 | - (FSSwitchState)stateForSwitchIdentifier:(NSString *)switchIdentifier { 16 | // Update setting 17 | NSDictionary *preferences = [NSDictionary dictionaryWithContentsOfFile:kPrefPath]; 18 | 19 | BOOL enabled = [preferences[@"enabled"] boolValue]; 20 | return (enabled) ? FSSwitchStateOn : FSSwitchStateOff; 21 | } 22 | 23 | - (void)applyState:(FSSwitchState)newState forSwitchIdentifier:(NSString *)switchIdentifier { 24 | if (newState == FSSwitchStateIndeterminate) 25 | return; 26 | 27 | // Save changes 28 | NSMutableDictionary *preferences = [NSMutableDictionary dictionaryWithContentsOfFile:kPrefPath]; 29 | preferences[@"enabled"] = @(newState); 30 | [preferences writeToFile:kPrefPath atomically:YES]; 31 | 32 | // Notify tweak 33 | notify_post(kFlipswitchNotification); 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /preferences/CLDPrefsRootListController.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "../../TwitterStuff/Prompt.h" 3 | #import "../Common.h" 4 | #import 5 | 6 | @interface CLDPrefsRootListController : PSListController 7 | @end 8 | 9 | 10 | @implementation CLDPrefsRootListController 11 | 12 | - (void)setCellForRowAtIndexPath:(NSIndexPath *)indexPath enabled:(BOOL)enabled { 13 | UITableViewCell *cell = [self tableView:self.table cellForRowAtIndexPath:indexPath]; 14 | if (cell) { 15 | cell.userInteractionEnabled = enabled; 16 | cell.textLabel.enabled = enabled; 17 | cell.detailTextLabel.enabled = enabled; 18 | 19 | if ([cell isKindOfClass:[PSControlTableCell class]]) { 20 | PSControlTableCell *controlCell = (PSControlTableCell *)cell; 21 | if (controlCell.control) 22 | controlCell.control.enabled = enabled; 23 | } 24 | } 25 | } 26 | 27 | - (id)readPreferenceValue:(PSSpecifier*)specifier { 28 | NSDictionary *preferences = [NSDictionary dictionaryWithContentsOfFile:kPrefPath]; 29 | 30 | NSString *key = [specifier propertyForKey:@"key"]; 31 | if (!preferences[key]) 32 | return specifier.properties[@"default"]; 33 | 34 | if ([key isEqualToString:@"enabled"]) { 35 | BOOL enableCell = [[preferences objectForKey:key] boolValue]; 36 | [self setCellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:1] enabled:enableCell]; 37 | [self setCellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:2] enabled:enableCell]; 38 | 39 | if (enableCell ^ [[preferences objectForKey:@"chargeMode"] boolValue]) 40 | [self setCellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:2] enabled:NO]; 41 | else 42 | [self setCellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:2] enabled:enableCell]; 43 | } 44 | 45 | return preferences[key]; 46 | } 47 | 48 | 49 | - (void)setPreferenceValue:(id)value specifier:(PSSpecifier *)specifier { 50 | NSMutableDictionary *preferences = [NSMutableDictionary dictionaryWithContentsOfFile:kPrefPath]; 51 | NSString *key = [specifier propertyForKey:@"key"]; 52 | 53 | if ([key isEqualToString:@"chargeMode"]) 54 | [self setCellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:2] enabled:[value boolValue]]; 55 | 56 | if ([key isEqualToString:@"enabled"]) { 57 | [self setCellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:1] enabled:[value boolValue]]; 58 | [self setCellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:2] enabled:[value boolValue]]; 59 | 60 | if ([value boolValue] ^ [[preferences objectForKey:@"chargeMode"] boolValue]) 61 | [self setCellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:2] enabled:NO]; 62 | else 63 | [self setCellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:2] enabled:[value boolValue]]; 64 | } 65 | 66 | [preferences setObject:value forKey:key]; 67 | [preferences writeToFile:kPrefPath atomically:YES]; 68 | CFStringRef post = (CFStringRef)CFBridgingRetain(specifier.properties[@"PostNotification"]); 69 | CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), post, NULL, NULL, YES); 70 | } 71 | 72 | - (NSArray *)specifiers { 73 | if (!_specifiers) 74 | _specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self]; 75 | 76 | return _specifiers; 77 | } 78 | 79 | - (void)loadView { 80 | [super loadView]; 81 | 82 | int _; 83 | notify_register_dispatch(kFlipswitchNotification, &_, dispatch_get_main_queue(), ^(int _) { 84 | [self reloadSpecifiers]; 85 | }); 86 | 87 | presentFollowAlert(kPrefPath, self); 88 | } 89 | 90 | - (void)donate { 91 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://paypal.me/aNosskirneh"]]; 92 | } 93 | 94 | - (void)sendEmail { 95 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:andreaskhenriksson@gmail.com?subject=CustomLockscreenDuration"]]; 96 | } 97 | 98 | - (void)sourceCode { 99 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://github.com/Nosskirneh/CustomLockscreenDuration"]]; 100 | } 101 | 102 | - (void)icon { 103 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://emojione.com/"]]; 104 | } 105 | 106 | @end 107 | 108 | @interface CLDHeaderCell : PSTableCell 109 | @end 110 | 111 | @implementation CLDHeaderCell { 112 | UILabel *_headerLabel; 113 | UILabel *_subheaderLabel; 114 | } 115 | 116 | - (id)initWithSpecifier:(PSSpecifier *)specifier { 117 | self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell" specifier:specifier]; 118 | if (self) { 119 | UIFont *font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:24]; 120 | 121 | _headerLabel = [[UILabel alloc] init]; 122 | [_headerLabel setText:@"CustomLockscreenDuration"]; 123 | [_headerLabel setFont:font]; 124 | 125 | _subheaderLabel = [[UILabel alloc] init]; 126 | [_subheaderLabel setText:@"by Andreas Henriksson"]; 127 | [_subheaderLabel setTextColor:[UIColor grayColor]]; 128 | [_subheaderLabel setFont:[font fontWithSize:17]]; 129 | 130 | [self addSubview:_headerLabel]; 131 | [self addSubview:_subheaderLabel]; 132 | } 133 | return self; 134 | } 135 | 136 | - (void)layoutSubviews { 137 | [super layoutSubviews]; 138 | 139 | [_headerLabel sizeToFit]; 140 | [_subheaderLabel sizeToFit]; 141 | 142 | CGRect frame = _headerLabel.frame; 143 | frame.origin.y = 20; 144 | frame.origin.x = self.frame.size.width / 2 - _headerLabel.frame.size.width / 2; 145 | _headerLabel.frame = frame; 146 | 147 | frame.origin.y += _headerLabel.frame.size.height; 148 | frame.origin.x = self.frame.size.width / 2 - _subheaderLabel.frame.size.width / 2; 149 | _subheaderLabel.frame = frame; 150 | } 151 | 152 | - (CGFloat)preferredHeightForWidth:(CGFloat)width { 153 | // Return a custom cell height. 154 | return 80; 155 | } 156 | 157 | @end 158 | 159 | // Colorful UISwitches 160 | @interface PSSwitchTableCell : PSControlTableCell 161 | - (id)initWithStyle:(int)style reuseIdentifier:(id)identifier specifier:(id)specifier; 162 | @end 163 | 164 | @interface CLDSwitchTableCell : PSSwitchTableCell 165 | @end 166 | 167 | @implementation CLDSwitchTableCell 168 | 169 | - (id)initWithStyle:(int)style reuseIdentifier:(id)identifier specifier:(id)specifier { 170 | self = [super initWithStyle:style reuseIdentifier:identifier specifier:specifier]; 171 | if (self) 172 | [((UISwitch *)[self control]) setOnTintColor:[UIColor colorWithRed:0.00 green:0.48 blue:1.00 alpha:1.0]]; 173 | return self; 174 | } 175 | 176 | @end 177 | -------------------------------------------------------------------------------- /preferences/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = iphone:clang:9.2 2 | ARCHS = armv7s arm64 arm64e 3 | 4 | include $(THEOS)/makefiles/common.mk 5 | 6 | BUNDLE_NAME = CLDPrefs 7 | $(BUNDLE_NAME)_FILES = CLDPrefsRootListController.m ../../TwitterStuff/Prompt.m 8 | $(BUNDLE_NAME)_CFLAGS = -fobjc-arc 9 | $(BUNDLE_NAME)_INSTALL_PATH = /Library/PreferenceBundles 10 | $(BUNDLE_NAME)_FRAMEWORKS = UIKit 11 | $(BUNDLE_NAME)_PRIVATE_FRAMEWORKS = Preferences 12 | 13 | include $(THEOS_MAKE_PATH)/bundle.mk 14 | 15 | internal-stage:: 16 | $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) 17 | $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/CLDPrefs.plist$(ECHO_END) 18 | -------------------------------------------------------------------------------- /preferences/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | CLDPrefs 9 | CFBundleIdentifier 10 | se.nosskirneh.cldprefs 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.0 21 | NSPrincipalClass 22 | CLDPrefsRootListController 23 | 24 | 25 | -------------------------------------------------------------------------------- /preferences/Resources/Root.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | 9 | cell 10 | PSGroupCell 11 | headerCellClass 12 | CLDHeaderCell 13 | 14 | 15 | 16 | 17 | 18 | cell 19 | PSGroupCell 20 | label 21 | Settings 22 | 23 | 24 | 25 | cell 26 | PSSwitchCell 27 | cellClass 28 | CLDSwitchTableCell 29 | default 30 | 31 | key 32 | enabled 33 | label 34 | Enabled 35 | PostNotification 36 | se.nosskirneh.customlockscreenduration/preferencesChanged 37 | 38 | 39 | 40 | cell 41 | PSSegmentCell 42 | defaults 43 | se.nosskirneh.customlockduration 44 | key 45 | duration 46 | validTitles 47 | 48 | 2 49 | 7 50 | 10 51 | 16 52 | 20 53 | 26 54 | 31 55 | 40 56 | 57 | 58 | validValues 59 | 60 | 2 61 | 1 62 | 3 63 | 4 64 | 5 65 | 6 66 | 7 67 | 8 68 | 0 69 | 70 | default 71 | 1 72 | PostNotification 73 | se.nosskirneh.customlockscreenduration/preferencesChanged 74 | 75 | 76 | 77 | cell 78 | PSGroupCell 79 | 80 | 81 | 82 | cell 83 | PSSwitchCell 84 | cellClass 85 | CLDSwitchTableCell 86 | default 87 | 88 | key 89 | chargeMode 90 | label 91 | Differentiate on charging 92 | PostNotification 93 | se.nosskirneh.customlockscreenduration/preferencesChanged 94 | 95 | 96 | 97 | cell 98 | PSSegmentCell 99 | key 100 | chargingDuration 101 | validTitles 102 | 103 | 2 104 | 7 105 | 10 106 | 16 107 | 20 108 | 26 109 | 31 110 | 40 111 | 112 | 113 | validValues 114 | 115 | 2 116 | 1 117 | 3 118 | 4 119 | 5 120 | 6 121 | 7 122 | 8 123 | 0 124 | 125 | default 126 | 1 127 | PostNotification 128 | se.nosskirneh.customlockscreenduration/preferencesChanged 129 | 130 | 131 | 132 | 133 | cell 134 | PSGroupCell 135 | label 136 | About 137 | 138 | 139 | action 140 | sendEmail 141 | icon 142 | mail.png 143 | cell 144 | PSButtonCell 145 | label 146 | Email me with issues 147 | 148 | 149 | action 150 | donate 151 | cell 152 | PSButtonCell 153 | icon 154 | donate.png 155 | label 156 | Buy me a beer 157 | 158 | 159 | action 160 | sourceCode 161 | cell 162 | PSButtonCell 163 | icon 164 | github.png 165 | label 166 | Source code on GitHub 167 | 168 | 169 | action 170 | icon 171 | cell 172 | PSButtonCell 173 | icon 174 | icon.png 175 | label 176 | Icon taken from EmojiOne 177 | 178 | 179 | cell 180 | PSGroupCell 181 | footerAlignment 182 | 1 183 | footerText 184 | © 2018-2019 Andreas Henriksson 185 | 186 | 187 | 188 | title 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /preferences/Resources/donate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nosskirneh/CustomLockscreenDuration/cf02198d24ef444063eeb8bd95830895e4420240/preferences/Resources/donate.png -------------------------------------------------------------------------------- /preferences/Resources/donate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nosskirneh/CustomLockscreenDuration/cf02198d24ef444063eeb8bd95830895e4420240/preferences/Resources/donate@2x.png -------------------------------------------------------------------------------- /preferences/Resources/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nosskirneh/CustomLockscreenDuration/cf02198d24ef444063eeb8bd95830895e4420240/preferences/Resources/github.png -------------------------------------------------------------------------------- /preferences/Resources/github@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nosskirneh/CustomLockscreenDuration/cf02198d24ef444063eeb8bd95830895e4420240/preferences/Resources/github@2x.png -------------------------------------------------------------------------------- /preferences/Resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nosskirneh/CustomLockscreenDuration/cf02198d24ef444063eeb8bd95830895e4420240/preferences/Resources/icon.png -------------------------------------------------------------------------------- /preferences/Resources/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nosskirneh/CustomLockscreenDuration/cf02198d24ef444063eeb8bd95830895e4420240/preferences/Resources/icon@2x.png -------------------------------------------------------------------------------- /preferences/Resources/mail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nosskirneh/CustomLockscreenDuration/cf02198d24ef444063eeb8bd95830895e4420240/preferences/Resources/mail.png -------------------------------------------------------------------------------- /preferences/Resources/mail@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nosskirneh/CustomLockscreenDuration/cf02198d24ef444063eeb8bd95830895e4420240/preferences/Resources/mail@2x.png -------------------------------------------------------------------------------- /preferences/entry.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | entry 6 | 7 | bundle 8 | CLDPrefs 9 | cell 10 | PSLinkCell 11 | detail 12 | CLDPrefsRootListController 13 | icon 14 | icon.png 15 | isController 16 | 17 | label 18 | CustomLockscreenDuration 19 | 20 | 21 | 22 | --------------------------------------------------------------------------------