mirror of
https://github.com/ish-app/ish.git
synced 2026-01-25 14:06:40 +00:00
A bunch of people have tried to build the app from source and got confused when it crashed, because they customized the app group but didn't update the preprocessor macro. Now the app reads its app group off the mach-o on disk. This also fixes AltStore, which has to change app group names too. Fixes #650
123 lines
4.8 KiB
Objective-C
123 lines
4.8 KiB
Objective-C
//
|
|
// AboutViewController.m
|
|
// iSH
|
|
//
|
|
// Created by Theodore Dubois on 9/23/18.
|
|
//
|
|
|
|
#import "UIApplication+OpenURL.h"
|
|
#import "AboutViewController.h"
|
|
#import "UserPreferences.h"
|
|
#import "AppGroup.h"
|
|
|
|
@interface AboutViewController ()
|
|
@property (weak, nonatomic) IBOutlet UITableViewCell *capsLockMappingCell;
|
|
@property (weak, nonatomic) IBOutlet UITableViewCell *themeCell;
|
|
@property (weak, nonatomic) IBOutlet UISwitch *disableDimmingSwitch;
|
|
@property (weak, nonatomic) IBOutlet UITextField *launchCommandField;
|
|
@property (weak, nonatomic) IBOutlet UITextField *bootCommandField;
|
|
|
|
@property (weak, nonatomic) IBOutlet UITableViewCell *sendFeedback;
|
|
@property (weak, nonatomic) IBOutlet UITableViewCell *openGithub;
|
|
@property (weak, nonatomic) IBOutlet UITableViewCell *openTwitter;
|
|
@property (weak, nonatomic) IBOutlet UITableViewCell *openDiscord;
|
|
|
|
@property (weak, nonatomic) IBOutlet UITableViewCell *exportContainerCell;
|
|
|
|
@end
|
|
|
|
@implementation AboutViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self _addObservers];
|
|
[self _updatePreferenceUI];
|
|
}
|
|
|
|
- (void)dealloc {
|
|
[self _removeObservers];
|
|
}
|
|
|
|
- (void)_addObservers {
|
|
UserPreferences *prefs = [UserPreferences shared];
|
|
NSKeyValueObservingOptions opts = NSKeyValueObservingOptionNew;
|
|
|
|
[prefs addObserver:self forKeyPath:@"capsLockMapping" options:opts context:nil];
|
|
[prefs addObserver:self forKeyPath:@"fontSize" options:opts context:nil];
|
|
[prefs addObserver:self forKeyPath:@"launchCommand" options:opts context:nil];
|
|
[prefs addObserver:self forKeyPath:@"bootCommand" options:opts context:nil];
|
|
}
|
|
|
|
- (void)_removeObservers {
|
|
@try {
|
|
UserPreferences *prefs = [UserPreferences shared];
|
|
[prefs removeObserver:self forKeyPath:@"capsLockMapping"];
|
|
[prefs removeObserver:self forKeyPath:@"fontSize"];
|
|
[prefs removeObserver:self forKeyPath:@"launchCommand"];
|
|
[prefs removeObserver:self forKeyPath:@"bootCommand"];
|
|
} @catch (NSException * __unused exception) {}
|
|
}
|
|
|
|
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
|
if ([object isKindOfClass:[UserPreferences class]]) {
|
|
[self _updatePreferenceUI];
|
|
} else {
|
|
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
|
}
|
|
}
|
|
|
|
- (void)_updatePreferenceUI {
|
|
UserPreferences *prefs = UserPreferences.shared;
|
|
self.themeCell.detailTextLabel.text = prefs.theme.presetName;
|
|
self.disableDimmingSwitch.on = UserPreferences.shared.shouldDisableDimming;
|
|
self.launchCommandField.text = [UserPreferences.shared.launchCommand componentsJoinedByString:@" "];
|
|
self.bootCommandField.text = [UserPreferences.shared.bootCommand componentsJoinedByString:@" "];
|
|
}
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
|
|
if (cell == self.sendFeedback) {
|
|
[UIApplication openURL:@"mailto:tblodt@icloud.com?subject=Feedback%20for%20iSH"];
|
|
} else if (cell == self.openGithub) {
|
|
[UIApplication openURL:@"https://github.com/tbodt/ish"];
|
|
} else if (cell == self.openTwitter) {
|
|
[UIApplication openURL:@"https://twitter.com/tblodt"];
|
|
} else if (cell == self.openDiscord) {
|
|
[UIApplication openURL:@"https://discord.gg/SndDh5y"];
|
|
} else if (cell == self.exportContainerCell) {
|
|
// copy the files to the app container so they can be extracted from iTunes file sharing
|
|
NSURL *container = ContainerURL();
|
|
NSURL *documents = [NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0];
|
|
[NSFileManager.defaultManager removeItemAtURL:[documents URLByAppendingPathComponent:@"roots copy"] error:nil];
|
|
[NSFileManager.defaultManager copyItemAtURL:[container URLByAppendingPathComponent:@"roots"]
|
|
toURL:[documents URLByAppendingPathComponent:@"roots copy"]
|
|
error:nil];
|
|
}
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
}
|
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
NSInteger sections = [super numberOfSectionsInTableView:tableView];
|
|
if (!self.includeDebugPanel)
|
|
sections--;
|
|
return sections;
|
|
}
|
|
|
|
- (IBAction)disableDimmingChanged:(id)sender {
|
|
UserPreferences.shared.shouldDisableDimming = self.disableDimmingSwitch.on;
|
|
}
|
|
|
|
- (IBAction)textBoxSubmit:(id)sender {
|
|
[sender resignFirstResponder];
|
|
}
|
|
|
|
- (IBAction)launchCommandChanged:(id)sender {
|
|
UserPreferences.shared.launchCommand = [self.launchCommandField.text componentsSeparatedByString:@" "];
|
|
}
|
|
|
|
- (IBAction)bootCommandChanged:(id)sender {
|
|
UserPreferences.shared.bootCommand = [self.bootCommandField.text componentsSeparatedByString:@" "];
|
|
}
|
|
|
|
@end
|