如何从“设置”窗格中指定“激活器”操作

时间:2014-11-06 10:59:18

标签: ios objective-c jailbreak theos tweak

我按照本指南http://www.iphonedevwiki.net/index.php/Libactivator更改设置窗格(设置应用程序)中的激活方法。它不起作用。但我通过Activator更改激活方法(从Cydia源下载并安装),它正常工作。那么,我的错误在哪里?

控制

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

生成文件

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

1 个答案:

答案 0 :(得分:2)

我尝试了很多解决方案,但我找到了正确的解决方案。我需要修改LAListener实现

#1:为听众添加标题

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

#2:更改听众姓名

之前:

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

之后:

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