mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2024-11-21 12:30:50 +00:00
add info to about section in settings
This commit is contained in:
parent
5d01ae75f8
commit
e719c2a191
@ -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 = "<group>"; };
|
||||
/* 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 = "<group>";
|
||||
@ -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 */,
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
|
@ -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<NSDictionary<NSString*,NSString*>*> *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<NSString*,NSString*> *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
|
||||
|
47
Mini vMac/about.plist
Normal file
47
Mini vMac/about.plist
Normal file
@ -0,0 +1,47 @@
|
||||
<?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>title</key>
|
||||
<string>About</string>
|
||||
<key>items</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>text</key>
|
||||
<string>Version</string>
|
||||
<key>detailText</key>
|
||||
<string>$version</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>text</key>
|
||||
<string>Core</string>
|
||||
<key>detailText</key>
|
||||
<string>kAppVariationStr</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>text</key>
|
||||
<string>Maintainer</string>
|
||||
<key>detailText</key>
|
||||
<string>kMaintainerName</string>
|
||||
<key>link</key>
|
||||
<string>https://twitter.com/maczydeco</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>text</key>
|
||||
<string>Source Code</string>
|
||||
<key>detailText</key>
|
||||
<string>GitHub</string>
|
||||
<key>link</key>
|
||||
<string>https://github.com/zydeco/minivmac4ios</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>footer.html</key>
|
||||
<string>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></string>
|
||||
</dict>
|
||||
</plist>
|
@ -1,5 +1,3 @@
|
||||
//#include <Carbon/Carbon.h>
|
||||
//#include <AGL/agl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MyAppIsBundle 1
|
||||
|
Loading…
Reference in New Issue
Block a user