From ad60e4898b091ebc25c6d023b0e30ff82da25689 Mon Sep 17 00:00:00 2001 From: Huge_Black Date: Thu, 2 Jan 2025 23:02:21 +0800 Subject: [PATCH] fix #291, impelement #285 --- LiveContainerSwiftUI/LCSettingsView.swift | 14 +++++++++ LiveContainerSwiftUI/Localizable.xcstrings | 34 ++++++++++++++++++++++ NSUserDefaults.m | 2 +- Resources/Info.plist | 4 +-- TweakLoader/UIKit+GuestHooks.m | 5 ++++ control | 2 +- 6 files changed, 57 insertions(+), 4 deletions(-) diff --git a/LiveContainerSwiftUI/LCSettingsView.swift b/LiveContainerSwiftUI/LCSettingsView.swift index 3bed32c..8d31398 100644 --- a/LiveContainerSwiftUI/LCSettingsView.swift +++ b/LiveContainerSwiftUI/LCSettingsView.swift @@ -34,6 +34,7 @@ struct LCSettingsView: View { @State var isSignOnlyOnExpiration = true @State var frameShortIcon = false @State var silentSwitchApp = false + @State var silentOpenWebPage = false @State var injectToLCItelf = false @State var strictHiding = false @AppStorage("dynamicColors") var dynamicColors = true @@ -58,6 +59,7 @@ struct LCSettingsView: View { _isSignOnlyOnExpiration = State(initialValue: LCUtils.appGroupUserDefault.bool(forKey: "LCSignOnlyOnExpiration")) _frameShortIcon = State(initialValue: UserDefaults.standard.bool(forKey: "LCFrameShortcutIcons")) _silentSwitchApp = State(initialValue: UserDefaults.standard.bool(forKey: "LCSwitchAppWithoutAsking")) + _silentOpenWebPage = State(initialValue: UserDefaults.standard.bool(forKey: "LCOpenWebPageWithoutAsking")) _injectToLCItelf = State(initialValue: UserDefaults.standard.bool(forKey: "LCLoadTweaksToSelf")) _isSideStore = State(initialValue: LCUtils.store() == .SideStore) @@ -202,6 +204,15 @@ struct LCSettingsView: View { } footer: { Text("lc.settings.silentSwitchAppDesc".loc) } + + Section { + Toggle(isOn: $silentOpenWebPage) { + Text("lc.settings.silentOpenWebPage".loc) + } + } footer: { + Text("lc.settings.silentOpenWebPageDesc".loc) + } + if sharedModel.developerMode { Section { Toggle(isOn: $injectToLCItelf) { @@ -365,6 +376,9 @@ struct LCSettingsView: View { .onChange(of: silentSwitchApp) { newValue in saveItem(key: "LCSwitchAppWithoutAsking", val: newValue) } + .onChange(of: silentOpenWebPage) { newValue in + saveItem(key: "LCOpenWebPageWithoutAsking", val: newValue) + } .onChange(of: frameShortIcon) { newValue in saveItem(key: "LCFrameShortcutIcons", val: newValue) } diff --git a/LiveContainerSwiftUI/Localizable.xcstrings b/LiveContainerSwiftUI/Localizable.xcstrings index 03e44fb..3364ac4 100644 --- a/LiveContainerSwiftUI/Localizable.xcstrings +++ b/LiveContainerSwiftUI/Localizable.xcstrings @@ -3091,6 +3091,40 @@ } } }, + "lc.settings.silentOpenWebPage" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Always Open URL in Current App" + } + }, + "zh_CN" : { + "stringUnit" : { + "state" : "translated", + "value" : "总是在当前App打开链接" + } + } + } + }, + "lc.settings.silentOpenWebPageDesc" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "By default, LiveContainer asks you how to open an URL. Enable this automatically open URL in current app." + } + }, + "zh_CN" : { + "stringUnit" : { + "state" : "translated", + "value" : "LiveContainer在打开链接时会询问你如何打开。启用此选项来自动在当前App中打开。" + } + } + } + }, "lc.settings.silentSwitchApp" : { "extractionState" : "manual", "localizations" : { diff --git a/NSUserDefaults.m b/NSUserDefaults.m index 8fbf377..64b3f17 100644 --- a/NSUserDefaults.m +++ b/NSUserDefaults.m @@ -211,7 +211,7 @@ - (void) hook_removePersistentDomainForName:(NSString*)domainName { [self hook_removePersistentDomainForName:domainName]; } else { // empty dictionary means deletion - [LCPreferences setObject:[[NSMutableArray alloc] init] forKey:domainName]; + [LCPreferences setObject:[[NSMutableDictionary alloc] init] forKey:domainName]; LCSavePreference(); } NSURL* preferenceFilePath = LCGetPreferencePath(domainName); diff --git a/Resources/Info.plist b/Resources/Info.plist index 855474f..0a16841 100644 --- a/Resources/Info.plist +++ b/Resources/Info.plist @@ -42,7 +42,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 3.1.56 + 3.1.57 CFBundleSignature ???? CFBundleSupportedPlatforms @@ -61,7 +61,7 @@ CFBundleVersion - 3.1.56 + 3.1.57 LSApplicationCategoryType public.app-category.games LSApplicationQueriesSchemes diff --git a/TweakLoader/UIKit+GuestHooks.m b/TweakLoader/UIKit+GuestHooks.m index 78ffe71..3bf020e 100644 --- a/TweakLoader/UIKit+GuestHooks.m +++ b/TweakLoader/UIKit+GuestHooks.m @@ -141,6 +141,11 @@ void openUniversalLink(NSString* decodedUrl) { } void LCOpenWebPage(NSString* webPageUrlString, NSString* originalUrl) { + if ([NSUserDefaults.lcUserDefaults boolForKey:@"LCOpenWebPageWithoutAsking"]) { + openUniversalLink(webPageUrlString); + return; + } + NSString *message = @"lc.guestTweak.openWebPageTip".loc; UIWindow *window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"LiveContainer" message:message preferredStyle:UIAlertControllerStyleAlert]; diff --git a/control b/control index 6740a90..09b1b95 100644 --- a/control +++ b/control @@ -1,6 +1,6 @@ Package: com.kdt.livecontainer Name: livecontainer -Version: 3.1.56 +Version: 3.1.57 Architecture: iphoneos-arm Description: Run iOS app without actually installing it! Maintainer: khanhduytran0