3

I'm following this guide http://www.iphonedevwiki.net/index.php/Libactivator to change activation method from the Settings Pane (Settings application). It doesn't work. But I change activation method via Activator (download and install from Cydia source), it work properly. So, where's my mistake?

control

Package: com.example.mytweak
Name: MyTweak
Description: A simple MobileSubstrate tweak!
Version: 0.0.1
Priority: optional
Section: Tweaks
Architecture: iphoneos-arm
Depends: mobilesubstrate, libactivator
Maintainer: Maintainer name
Author: Author name

Makefile

include theos/makefiles/common.mk

TWEAK_NAME = MyTweak
MyTweak_FILES = Tweak.xm
MyTweak_FRAMEWORKS = UIKit AVFoundation
MyTweak_LIBRARIES = activator

include $(THEOS_MAKE_PATH)/tweak.mk

internal-stage::
    #PreferenceLoader plist
    $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END)
    $(ECHO_NOTHING)cp Preferences.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/MyTweak.plist$(ECHO_END)

after-install::
    install.exec "killall -9 SpringBoard"

MyTweak.plist

<?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>Filter</key>
    <dict>
        <key>Bundles</key>
        <array>
            <string>com.apple.springboard</string>
        </array>
    </dict>
</dict>
</plist>

Preferences.plist

<?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>cell</key>
        <string>PSLinkCell</string>
        <key>defaults</key>
        <string>com.example.mytweak</string>
        <key>label</key>
        <string>MyTweak</string>
        <key>key</key>
        <string>enabled</string>
        <key>default</key>
        <true/>
        <key>icon</key>
        <string>/Applications/Preferences.app/icon-table@2x.png</string>
        <key>PostNotification</key>
        <string>com.example.mytweak/preferences.changed</string>
        <key>items</key>
        <array>
            <dict>
                <key>cell</key>
                <string>PSLinkCell</string>
                <key>label</key>
                <string>Activation Methods</string>
                <key>isController</key>
                <true/>
                <key>bundle</key>
                <string>LibActivator</string>
                <key>activatorListener</key>
                <string>com.example.mytweak</string>
            </dict>
        </array>
    </dict>
</dict>
</plist>

Tweak.xm

#import <libactivator/libactivator.h>

@interface MyTweakListener : NSObject <LAListener>
@end

@implementation MyTweakListener

- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event {
    //  Do something
    [event setHandled:YES];
}

- (void)activator:(LAActivator *)activator abortEvent:(LAEvent *)event {
    //  Do something
}

+ (void)load {
    if ([LASharedActivator isRunningInsideSpringBoard]) {
        [LASharedActivator registerListener:[self new] forName:@"MyTweak"];
    }
}

@end
Minh Quy
  • 655
  • 5
  • 21

1 Answers1

2

I tried many solutions and I found the correct solution. I need to modify LAListener implemement

#1: Add title for listener

- (NSString *)activator:(LAActivator *)activator requiresLocalizedTitleForListenerName:(NSString *)listenerName {
    return @"onClan Assistive Touch";
}

#2: Change listener name

before:

+ (void)load {
    if ([LASharedActivator isRunningInsideSpringBoard]) {
        [LASharedActivator registerListener:[self new] forName:@"MyTweak"];
    }
}

after:

+ (void)load {
    if ([LASharedActivator isRunningInsideSpringBoard]) {
        [LASharedActivator registerListener:[self new] forName:@"com.example.mytweak"];
    }
}
Minh Quy
  • 655
  • 5
  • 21