Skip to content
This repository has been archived by the owner on Dec 27, 2021. It is now read-only.

Commit

Permalink
Add custom lock glyph sizing (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
aydenp committed Mar 4, 2017
1 parent d33bd29 commit 0dbb5e0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
16 changes: 16 additions & 0 deletions LockGlyphX.xm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#define kDefaultYOffset 90.0f
#define kDefaultYOffsetWithLockLabelHidden 64.0f

#define kDefaultGlyphSize 63.0f

#define kSoundNone 0
#define kSoundTheme 1
#define kSoundApplePay 2
Expand Down Expand Up @@ -91,6 +93,8 @@ static BOOL enablePortraitX;
static CGFloat portraitX;
static BOOL enableLandscapeX;
static CGFloat landscapeX;
static BOOL enableSize;
static CGFloat customSize;
static BOOL shouldHideRing;
static NSString *pressHomeToUnlockText;
static BOOL hidePressHomeToUnlockLabel;
Expand Down Expand Up @@ -173,6 +177,8 @@ static void loadPreferences() {
portraitX = !CFPreferencesCopyAppValue(CFSTR("portraitX"), kPrefsAppID) ? 0 : [CFBridgingRelease(CFPreferencesCopyAppValue(CFSTR("portraitX"), kPrefsAppID)) floatValue];
enableLandscapeX = !CFPreferencesCopyAppValue(CFSTR("enableLandscapeX"), kPrefsAppID) ? NO : [CFBridgingRelease(CFPreferencesCopyAppValue(CFSTR("enableLandscapeX"), kPrefsAppID)) boolValue];
landscapeX = !CFPreferencesCopyAppValue(CFSTR("landscapeX"), kPrefsAppID) ? 0 : [CFBridgingRelease(CFPreferencesCopyAppValue(CFSTR("landscapeX"), kPrefsAppID)) floatValue];
enableSize = !CFPreferencesCopyAppValue(CFSTR("enableSize"), kPrefsAppID) ? NO : [CFBridgingRelease(CFPreferencesCopyAppValue(CFSTR("enableSize"), kPrefsAppID)) boolValue];
customSize = !CFPreferencesCopyAppValue(CFSTR("customSize"), kPrefsAppID) ? kDefaultGlyphSize : [CFBridgingRelease(CFPreferencesCopyAppValue(CFSTR("customSize"), kPrefsAppID)) floatValue];
shouldHideRing = !CFPreferencesCopyAppValue(CFSTR("shouldHideRing"), kPrefsAppID) ? NO : [CFBridgingRelease(CFPreferencesCopyAppValue(CFSTR("shouldHideRing"), kPrefsAppID)) boolValue];
hidePressHomeToUnlockLabel = !CFPreferencesCopyAppValue(CFSTR("hidePressHomeToUnlockLabel"), kPrefsAppID) ? YES : [CFBridgingRelease(CFPreferencesCopyAppValue(CFSTR("hidePressHomeToUnlockLabel"), kPrefsAppID)) boolValue];
pressHomeToUnlockText = !CFPreferencesCopyAppValue(CFSTR("pressHomeToUnlockText"), kPrefsAppID) ? @"" : CFBridgingRelease(CFPreferencesCopyAppValue(CFSTR("pressHomeToUnlockText"), kPrefsAppID));
Expand Down Expand Up @@ -550,6 +556,16 @@ static void performShakeFingerFailAnimation(void) {
%hook PKGlyphView
%new
- (void)updatePositionWithOrientation:(UIInterfaceOrientation)orientation {
// Sizing:
CGRect frame = fingerglyph.frame;
CGFloat size = kDefaultGlyphSize;
if(enableSize && customSize != 0) {
size = customSize;
}
frame.size = CGSizeMake(size, size);
fingerglyph.frame = frame;

// Positioning:
CGRect screen = [[UIScreen mainScreen] bounds];
float dx, dy;

Expand Down
30 changes: 30 additions & 0 deletions Prefs/Resources/LockGlyphXPrefs-Appearance.plist
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,36 @@
<key>label</key>
<string>POSITION_LABEL</string>
</dict>
<!-- Use Custom Size -->
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>cellClass</key>
<string>LGXSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>com.evilgoldfish.lockglyphx</string>
<key>key</key>
<string>enableSize</string>
<key>label</key>
<string>FINGERSIZE_TOGL_LABEL</string>
<key>PostNotification</key>
<string>com.evilgoldfish.lockglyphx.settingschanged</string>
</dict>
<!-- Custom Size -->
<dict>
<key>cell</key>
<string>PSEditTextCell</string>
<key>label</key>
<string>FINGERSIZE_VALUE_LABEL</string>
<key>defaults</key>
<string>com.evilgoldfish.lockglyphx</string>
<key>key</key>
<string>customSize</string>
<key>PostNotification</key>
<string>com.evilgoldfish.lockglyphx.settingschanged</string>
</dict>

<!-- Custom Colors -->
<dict>
Expand Down
2 changes: 2 additions & 0 deletions Prefs/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"LOCKLABEL_CUSTOM_TEXT_ENABLED_LABEL" = "Use custom text";
"LOCKLABEL_CUSTOM_TEXT_LABEL" = "Custom text";
"POSITION_LABEL" = "Position";
"FINGERSIZE_TOGL_LABEL" = "Use Custom Size";
"FINGERSIZE_VALUE_LABEL" = "Custom Size";

/* Appearance > Position Page */
"POSITION_TITLE" = "Position";
Expand Down

0 comments on commit 0dbb5e0

Please sign in to comment.