Skip to content

Commit d9fc970

Browse files
committed
feat: use safariviewcontroller for github issue prefill
1 parent 3e00eaf commit d9fc970

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ include $(THEOS)/makefiles/common.mk
1111
TWEAK_NAME = Unbound
1212
$(TWEAK_NAME)_FILES = $(shell find sources -name "*.x*" -o -name "*.m*")
1313
$(TWEAK_NAME)_CFLAGS = -fobjc-arc -DPACKAGE_VERSION='@"$(THEOS_PACKAGE_BASE_VERSION)"' -DCOMMIT_HASH='@"$(COMMIT_HASH)"' -I$(THEOS_PROJECT_DIR)/headers
14-
$(TWEAK_NAME)_FRAMEWORKS = UIKit Foundation UniformTypeIdentifiers UserNotifications Security
14+
$(TWEAK_NAME)_FRAMEWORKS = UIKit Foundation UniformTypeIdentifiers UserNotifications Security SafariServices
1515

1616
BUNDLE_NAME = UnboundResources
1717
$(BUNDLE_NAME)_INSTALL_PATH = "/Library/Application\ Support/"

headers/Recovery.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#import <Foundation/Foundation.h>
22
#import <UIKit/UIKit.h>
33
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
4+
#import <SafariServices/SafariServices.h>
45
#import <objc/message.h>
56
#import <spawn.h>
67
#import <sys/utsname.h>
@@ -9,14 +10,15 @@
910
#import "Settings.h"
1011
#import "Updater.h"
1112
#import "Utilities.h"
13+
#import "MobileGestalt.h"
1214

1315
BOOL isRecoveryModeEnabled(void);
1416
void showMenuSheet(void);
1517
void reloadApp(UIViewController *viewController);
1618

1719
extern id gBridge;
1820

19-
@interface UnboundMenuViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
21+
@interface UnboundMenuViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, SFSafariViewControllerDelegate>
2022

2123
@property (nonatomic, strong) UITableView *tableView;
2224

sources/Recovery.x

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
#import "MobileGestalt.h"
21
#import "Recovery.h"
32

4-
#pragma mark - Gesture Handling
5-
63
static NSTimeInterval shakeStartTime = 0;
74
static BOOL isShaking = NO;
85
static NSHashTable *windowsWithGestures = nil;
@@ -329,8 +326,6 @@ BOOL isRecoveryModeEnabled(void)
329326
return cell;
330327
}
331328

332-
#pragma mark - Table View Delegate
333-
334329
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
335330
{
336331
[tableView deselectRowAtIndexPath:indexPath animated:YES];
@@ -347,8 +342,6 @@ BOOL isRecoveryModeEnabled(void)
347342
}
348343
}
349344

350-
#pragma mark - Menu Actions
351-
352345
- (void)showDestructiveConfirmation:(NSString *)action selectorName:(NSString *)selectorName
353346
{
354347
NSString *message = @"Are you sure you want to do this?";
@@ -407,8 +400,6 @@ BOOL isRecoveryModeEnabled(void)
407400
[self dismissViewControllerAnimated:YES completion:^{ reloadApp(self); }];
408401
}
409402

410-
#pragma mark - Bundle Management
411-
412403
- (void)switchBundleVersion
413404
{
414405
UIAlertController *loadingAlert =
@@ -701,8 +692,6 @@ BOOL isRecoveryModeEnabled(void)
701692
[self dismissViewControllerAnimated:YES completion:^{ reloadApp(self); }];
702693
}
703694

704-
#pragma mark - Utility Functions
705-
706695
- (void)openAppFolder
707696
{
708697
if ([Utilities isJailbroken])
@@ -787,7 +776,17 @@ BOOL isRecoveryModeEnabled(void)
787776
stringWithFormat:@"https://github.com/unbound-app/client/issues/new?title=%@&body=%@",
788777
encodedTitle, encodedBody];
789778
NSURL *url = [NSURL URLWithString:urlString];
790-
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
779+
780+
if (!url)
781+
{
782+
return;
783+
}
784+
785+
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
786+
safari.dismissButtonStyle = SFSafariViewControllerDismissButtonStyleClose;
787+
safari.delegate = self;
788+
safari.modalPresentationStyle = UIModalPresentationPageSheet;
789+
[self presentViewController:safari animated:YES completion:nil];
791790
}
792791

793792
- (void)toggleSetting:(UISwitch *)sender
@@ -850,13 +849,16 @@ BOOL isRecoveryModeEnabled(void)
850849
[defaults synchronize];
851850
}
852851

852+
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller
853+
{
854+
[controller dismissViewControllerAnimated:YES completion:nil];
855+
}
856+
853857
- (void)dismiss
854858
{
855859
[self dismissViewControllerAnimated:YES completion:nil];
856860
}
857861

858-
#pragma mark - Helper Functions
859-
860862
void showMenuSheet(void)
861863
{
862864
UnboundMenuViewController *settingsVC = [[UnboundMenuViewController alloc] init];

0 commit comments

Comments
 (0)