diff --git a/Mini vMac.xcodeproj/project.pbxproj b/Mini vMac.xcodeproj/project.pbxproj index af506c0..07fb139 100644 --- a/Mini vMac.xcodeproj/project.pbxproj +++ b/Mini vMac.xcodeproj/project.pbxproj @@ -58,6 +58,7 @@ 28F6B4C01CF07F5C002D76D0 /* liblibhfs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 28F6B48E1CF07DDD002D76D0 /* liblibhfs.a */; }; 28F6B4C11CF07F5C002D76D0 /* liblibmfs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 28F6B4A81CF07EC9002D76D0 /* liblibmfs.a */; }; 28F6B4C21CF07F5C002D76D0 /* liblibres.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 28F6B4B61CF07F32002D76D0 /* liblibres.a */; }; + 28F6B4CA1CF1FA7A002D76D0 /* about.plist in Resources */ = {isa = PBXBuildFile; fileRef = 28F6B4C91CF1FA7A002D76D0 /* about.plist */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -204,6 +205,7 @@ 28F6B48E1CF07DDD002D76D0 /* liblibhfs.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = liblibhfs.a; sourceTree = BUILT_PRODUCTS_DIR; }; 28F6B4A81CF07EC9002D76D0 /* liblibmfs.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = liblibmfs.a; sourceTree = BUILT_PRODUCTS_DIR; }; 28F6B4B61CF07F32002D76D0 /* liblibres.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = liblibres.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 28F6B4C91CF1FA7A002D76D0 /* about.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = about.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -359,6 +361,7 @@ 28F676C01CD15E0B00FC6FA6 /* Supporting Files */, 28F6B4501CF07C48002D76D0 /* UIImage+DiskImageIcon.h */, 28F6B4511CF07C48002D76D0 /* UIImage+DiskImageIcon.m */, + 28F6B4C91CF1FA7A002D76D0 /* about.plist */, ); path = "Mini vMac"; sourceTree = ""; @@ -563,6 +566,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 28F6B4CA1CF1FA7A002D76D0 /* about.plist in Resources */, 28F676D01CD15E0B00FC6FA6 /* LaunchScreen.storyboard in Resources */, 28F676CD1CD15E0B00FC6FA6 /* Assets.xcassets in Resources */, 28BA89821CE7336500A98104 /* Keyboard Layouts in Resources */, diff --git a/Mini vMac/Base.lproj/Main.storyboard b/Mini vMac/Base.lproj/Main.storyboard index af4db76..89bfffe 100644 --- a/Mini vMac/Base.lproj/Main.storyboard +++ b/Mini vMac/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + diff --git a/Mini vMac/SettingsViewController.m b/Mini vMac/SettingsViewController.m index 7a92369..cbe7624 100644 --- a/Mini vMac/SettingsViewController.m +++ b/Mini vMac/SettingsViewController.m @@ -8,6 +8,7 @@ #import "SettingsViewController.h" #import "AppDelegate.h" +#import "CNFGRAPI.h" @interface SettingsViewController () @@ -16,11 +17,34 @@ @implementation SettingsViewController { NSArray *keyboardLayouts; + NSString *aboutTitle; + NSArray*> *aboutItems; + UITextView *footerView; } - (void)viewDidLoad { [super viewDidLoad]; keyboardLayouts = [[NSBundle mainBundle] pathsForResourcesOfType:@"nfkeyboardlayout" inDirectory:@"Keyboard Layouts"]; + [self loadCredits]; +} + +- (void)loadCredits { + NSDictionary *aboutData = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"about" ofType:@"plist"]]; + aboutTitle = aboutData[@"title"]; + aboutItems = aboutData[@"items"]; + footerView = [[UITextView alloc] initWithFrame:CGRectZero]; + NSAttributedString *str = [[NSMutableAttributedString alloc] initWithData:[aboutData[@"footer.html"] dataUsingEncoding:NSUTF8StringEncoding] + options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, + NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)} + documentAttributes:nil + error:NULL]; + footerView.attributedText = str; + [footerView sizeToFit]; + footerView.editable = NO; + footerView.textAlignment = NSTextAlignmentCenter; + footerView.textColor = [UIColor darkGrayColor]; + footerView.font = [UIFont systemFontOfSize:[UIFont smallSystemFontSize]]; + footerView.backgroundColor = [UIColor clearColor]; } - (void)viewDidAppear:(BOOL)animated { @@ -62,6 +86,8 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 2) { return keyboardLayouts.count; + } else if (section == 3) { + return aboutItems.count; } else { return 1; } @@ -72,11 +98,27 @@ case 0: return NSLocalizedString(@"Speed", nil); case 1: return NSLocalizedString(@"Mouse Type", nil); case 2: return NSLocalizedString(@"Keyboard Layout", nil); - case 3: return NSLocalizedString(@"About", nil); + case 3: return aboutTitle; default: return nil; } } +- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { + if (section == 3) { + return footerView; + } else { + return nil; + } +} + +- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { + if (section == 3) { + return footerView.bounds.size.height; + } else { + return 0.0; + } +} + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; @@ -97,18 +139,40 @@ cell.accessoryType = selected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone; } else if (section == 3) { cell = [tableView dequeueReusableCellWithIdentifier:@"about" forIndexPath:indexPath]; + NSDictionary *item = aboutItems[indexPath.row]; + cell.textLabel.text = item[@"text"]; + NSString *detailText = item[@"detailText"]; + if ([detailText isEqualToString:@"$version"]) { + NSString *versionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; + NSString *commitString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"GitVersion"]; + cell.detailTextLabel.text = commitString.length > 0 ? [NSString stringWithFormat:@"%@ (%@)", versionString, commitString] : versionString; + } else if ([detailText isEqualToString:@"kAppVariationStr"]) { + cell.detailTextLabel.text = @(kAppVariationStr); + } else if ([detailText isEqualToString:@"kMaintainerName"]) { + cell.detailTextLabel.text = @(kMaintainerName); + } else { + cell.detailTextLabel.text = detailText; + } + cell.accessoryType = item[@"link"] == nil ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator; } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; if (indexPath.section == 2) { + // selected keyboard layout NSString *layout = keyboardLayouts[indexPath.row]; [defaults setValue:layout.lastPathComponent forKey:@"keyboardLayout"]; + [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic]; + } if (indexPath.section == 3) { + // links in about + NSString *linkURL = aboutItems[indexPath.row][@"link"]; + if (linkURL != nil) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:linkURL]]; + } } - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic]; } @end diff --git a/Mini vMac/about.plist b/Mini vMac/about.plist new file mode 100644 index 0000000..3866d2e --- /dev/null +++ b/Mini vMac/about.plist @@ -0,0 +1,47 @@ + + + + + title + About + items + + + text + Version + detailText + $version + + + text + Core + detailText + kAppVariationStr + + + text + Maintainer + detailText + kMaintainerName + link + https://twitter.com/maczydeco + + + text + Source Code + detailText + GitHub + link + https://github.com/zydeco/minivmac4ios + + + footer.html + Mini vMac for iOS<br/> +©2008-2016 Jesús A. Álvarez<br/> +<a href="https://namedfork.net/minivmac">namedfork.net/minivmac</a><br/> +<hr/> +based on Mini vMac<br/> +©2001-2016 Paul C. Pratt<br/> +<a href="http://gryphel.com/c/minivmac">gryphel.com/c/minivmac</a> + + diff --git a/Mini vMac/mnvm_cfg/CNFGRAPI.h b/Mini vMac/mnvm_cfg/CNFGRAPI.h index eccd480..3858fd5 100644 --- a/Mini vMac/mnvm_cfg/CNFGRAPI.h +++ b/Mini vMac/mnvm_cfg/CNFGRAPI.h @@ -1,5 +1,3 @@ -//#include -//#include #include #define MyAppIsBundle 1