mirror of
https://github.com/YuzuZensai/iOS-DiscordPresence.git
synced 2026-03-30 16:28:43 +00:00
Added Preferences
This commit is contained in:
13
Preferences/Makefile
Normal file
13
Preferences/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
TARGET := iphone:clang:latest:7.0
|
||||
|
||||
include $(THEOS)/makefiles/common.mk
|
||||
|
||||
BUNDLE_NAME = iOSDiscordPresencePreferences
|
||||
|
||||
iOSDiscordPresencePreferences_FILES = iOSDiscordPresenceRootListController.m
|
||||
iOSDiscordPresencePreferences_FRAMEWORKS = UIKit
|
||||
iOSDiscordPresencePreferences_PRIVATE_FRAMEWORKS = Preferences
|
||||
iOSDiscordPresencePreferences_INSTALL_PATH = /Library/PreferenceBundles
|
||||
iOSDiscordPresencePreferences_CFLAGS = -fobjc-arc
|
||||
|
||||
include $(THEOS_MAKE_PATH)/bundle.mk
|
||||
24
Preferences/Resources/Info.plist
Normal file
24
Preferences/Resources/Info.plist
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>iOSDiscordPresencePreferences</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>pink.kirameki.yuzu.iosdiscordpresencepreferences</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>iOSDiscordPresenceRootListController</string>
|
||||
</dict>
|
||||
</plist>
|
||||
69
Preferences/Resources/Root.plist
Normal file
69
Preferences/Resources/Root.plist
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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>items</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>cell</key>
|
||||
<string>PSStaticTextCell</string>
|
||||
<key>height</key>
|
||||
<integer>150</integer>
|
||||
<key>label</key>
|
||||
<string></string>
|
||||
<key>icon</key>
|
||||
<string>banner.png</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>cell</key>
|
||||
<string>PSGroupCell</string>
|
||||
<key>label</key>
|
||||
<string>General</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>cell</key>
|
||||
<string>PSSwitchCell</string>
|
||||
<key>default</key>
|
||||
<false/>
|
||||
<key>defaults</key>
|
||||
<string>pink.kirameki.yuzu.iosdiscordpresencepreferences</string>
|
||||
<key>key</key>
|
||||
<string>isEnabled</string>
|
||||
<key>label</key>
|
||||
<string>Enabled</string>
|
||||
<key>PostNotification</key>
|
||||
<string>pink.kirameki.yuzu.iosdiscordpresencepreferences/PreferencesChanged</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>cell</key>
|
||||
<string>PSSecureEditTextCell</string>
|
||||
<key>defaults</key>
|
||||
<string>pink.kirameki.yuzu.iosdiscordpresencepreferences</string>
|
||||
<key>key</key>
|
||||
<string>discordToken</string>
|
||||
<key>label</key>
|
||||
<string>Discord Token</string>
|
||||
<key>placeholder</key>
|
||||
<string>Put your discord token here</string>
|
||||
<key>PostNotification</key>
|
||||
<string>pink.kirameki.yuzu.iosdiscordpresencepreferences/PreferencesChanged</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>cell</key>
|
||||
<string>PSGroupCell</string>
|
||||
<key>label</key>
|
||||
<string>Information</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>cell</key>
|
||||
<string>PSButtonCell</string>
|
||||
<key>label</key>
|
||||
<string>GitHub</string>
|
||||
<key>action</key>
|
||||
<string>openGitHubLink</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>title</key>
|
||||
<string>iOS-DiscordPresence</string>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
Preferences/Resources/banner.png
Executable file
BIN
Preferences/Resources/banner.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 146 KiB |
BIN
Preferences/Resources/icon.png
Executable file
BIN
Preferences/Resources/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
BIN
Preferences/Resources/icon@2x.png
Executable file
BIN
Preferences/Resources/icon@2x.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
6
Preferences/iOSDiscordPresenceRootListController.h
Normal file
6
Preferences/iOSDiscordPresenceRootListController.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#import <Preferences/PSListController.h>
|
||||
#import <Preferences/PSSpecifier.h>
|
||||
|
||||
@interface iOSDiscordPresenceRootListController : PSListController
|
||||
|
||||
@end
|
||||
36
Preferences/iOSDiscordPresenceRootListController.m
Normal file
36
Preferences/iOSDiscordPresenceRootListController.m
Normal file
@@ -0,0 +1,36 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "iOSDiscordPresenceRootListController.h"
|
||||
|
||||
@implementation iOSDiscordPresenceRootListController
|
||||
|
||||
- (NSArray *)specifiers {
|
||||
if (!_specifiers) {
|
||||
_specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self];
|
||||
}
|
||||
|
||||
return _specifiers;
|
||||
}
|
||||
|
||||
-(id)readPreferenceValue:(PSSpecifier*)specifier {
|
||||
NSDictionary * prefs = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"/var/mobile/Library/Preferences/%@.plist", [specifier.properties objectForKey:@"defaults"]]];
|
||||
if (![prefs objectForKey:[specifier.properties objectForKey:@"key"]]) {
|
||||
return [specifier.properties objectForKey:@"default"];
|
||||
}
|
||||
return [prefs objectForKey:[specifier.properties objectForKey:@"key"]];
|
||||
}
|
||||
|
||||
-(void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier {
|
||||
NSMutableDictionary * prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"/var/mobile/Library/Preferences/%@.plist", [specifier.properties objectForKey:@"defaults"]]];
|
||||
[prefs setObject:value forKey:[specifier.properties objectForKey:@"key"]];
|
||||
[prefs writeToFile:[NSString stringWithFormat:@"/var/mobile/Library/Preferences/%@.plist", [specifier.properties objectForKey:@"defaults"]] atomically:YES];
|
||||
if([specifier.properties objectForKey:@"PostNotification"]) {
|
||||
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), (CFStringRef)[specifier.properties objectForKey:@"PostNotification"], NULL, NULL, YES);
|
||||
}
|
||||
[super setPreferenceValue:value specifier:specifier];
|
||||
}
|
||||
|
||||
- (void)openGitHubLink {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://github.com/YuzuZensai/iOS-DiscordPresence"]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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>bundle</key>
|
||||
<string>iOSDiscordPresencePreferences</string>
|
||||
<key>cell</key>
|
||||
<string>PSLinkCell</string>
|
||||
<key>detail</key>
|
||||
<string>iOSDiscordPresenceRootListController</string>
|
||||
<key>icon</key>
|
||||
<string>icon.png</string>
|
||||
<key>isController</key>
|
||||
<true/>
|
||||
<key>label</key>
|
||||
<string>iOS-DiscordPresence</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user