OlyDJ
iOS9 iOS9 iOS9 iOS9 iOS9 iOS9 iOS9 iOS9

Selecciona idioma

Spanish English

Adding custom text for "Slide to Unlock"

by OlyDJ

Do you want to be a iOS deveolper? It´s really easy to start if you follow this tutorials. In this tutorial we are going to hook Slide to Unlock text. To do it we need to add a PSEditTextCell to our preferences.


Custom Slide to Unlock text

    We have a tweak (firsttweak) with an option for disable Spotlight, so now we are going to add some stuff. Come on!


    • 01- Open up MobileTerminal and enter "su" and password. We are going to make a backup of our tweak folder, so if something is going wrong or whatever we can go back to a "stable" release. Type "cp /var/mobile/firsttweak /var/mobile/firsttweak.backup01" and hit Enter. Go inside our tweak folder (remember: "cd /var/mobile/firsttweak")

    This is what we have in "Tweak.xm" file:


    #define prefPath @"/User/Library/Preferences/com.oly.firsttweak.plist"


    static NSMutableDictionary *prefs;


    void refreshPrefs() {

    if(kCFCoreFoundationVersionNumber > 900.00) {

    [prefs release];

    CFStringRef appID2 = CFSTR("com.oly.firsttweak");

    CFArrayRef keyList = CFPreferencesCopyKeyList(appID2, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);

    if(keyList) {

    prefs = (NSMutableDictionary *)CFPreferencesCopyMultiple(keyList, appID2, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);

    CFRelease(keyList);

    } else {

    prefs = nil;

    }

    } else {

    [prefs release];

    prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:[prefPath stringByExpandingTildeInPath]];

    }

    }

    static void PreferencesChangedCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {

    refreshPrefs();

    }


    %hook SBSpotlightSettings

    -(BOOL)enableSpotlightOnMinusPage {

    if(prefs != nil && ([prefs count] != 0) && [[prefs objectForKey:@"enabled"] boolValue]) {

    return FALSE;

    } return %orig;

    }

    -(BOOL)enableSpotlightHomeScreenGesture {

    if(prefs != nil && ([prefs count] != 0) && [[prefs objectForKey:@"enabled"] boolValue]) {

    return FALSE;

    } return %orig;

    }

    %end


    %ctor {

    @autoreleasepool {

    prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:[prefPath stringByExpandingTildeInPath]];

    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback) PreferencesChangedCallback, CFSTR("com.oly.firsttweak.prefschanged"), NULL, CFNotificationSuspensionBehaviorCoalesce);

    refreshPrefs();

    }

    }



    • 02- Add this line after "#define prefPath...." line:

    #define kCustomSlideText [[NSDictionary dictionaryWithContentsOfFile:prefPath] objectForKey:@"customSlideText"]



    • 03- Now scroll down until "%end" (the closing hook) and add after it this:

    %hook SBLockScreenView

    -(void)setCustomSlideToUnlockText:(id)text {

    if(prefs != nil && ([prefs count] != 0) && [[prefs objectForKey:@"customTextEnabled"] boolValue]) {

    if ([kCustomSlideText isEqual:@""]) {

    %orig(@"");

    } else {

    text = kCustomSlideText;

    %orig(text);

    }

    } else {

    %orig(text);

    }

    }

    %end



    • 04- Save and close the Tweak.xm. Go inside "firsttweakprefs/Resources" and open "FirstTweakPrefs.plist" This is what we have right now:
    OlyDJ
    • 05- Add this lines after the Spotlight switch like here (before the "/array" line):
    OlyDJ
    • 13- Save the file, close it and delete the two "temporal" folders Theos created during first compilation, that folders are named: "_" and "obj". Now go to the "prefs" folder and delete de "obj" folder. Go back to MobileTerminal (remember that you already has logged with root and you are inside our root project folder), type "make package messages=yes" and hit Enter.

    We are compiling our tweak again, you will see how theos do the magic. If all is OK then you can go with iFile/Filza to our "debs" folder inside our project.


    Just install the last version (by now is the most weight file) and check preferences. Test it (remember that Spotlight method requires a Respring? Well, this one does not...).


Next tutorial: Some explanations and we will add a slider to control some stuff.