From 9583021fa3977799d833dcf631609d5c18c3d30f Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sun, 9 Oct 2016 19:47:35 +0200 Subject: [PATCH] [iOS] Add about dialog --- iOS/AboutController.h | 27 ++++++ iOS/AboutController.m | 97 ++++++++++++++++++++++ iOS/Base.lproj/Main.storyboard | 43 +++++++++- iOS/scrypt-pwgen.xcodeproj/project.pbxproj | 6 ++ 4 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 iOS/AboutController.h create mode 100644 iOS/AboutController.m diff --git a/iOS/AboutController.h b/iOS/AboutController.h new file mode 100644 index 0000000..54a4835 --- /dev/null +++ b/iOS/AboutController.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2016, Jonathan Schleifer + * + * https://heap.zone/git/?p=scrypt-pwgen.git + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice is present in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +@import UIKit; + +@interface AboutController: UIViewController +@property (retain, nonatomic) IBOutlet UIWebView *webView; +@end diff --git a/iOS/AboutController.m b/iOS/AboutController.m new file mode 100644 index 0000000..830217a --- /dev/null +++ b/iOS/AboutController.m @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2016, Jonathan Schleifer + * + * https://heap.zone/git/?p=scrypt-pwgen.git + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice is present in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#import "AboutController.h" + +static NSString *aboutHTMLTemplate = + @"" + @"" + @"" + @"" + @"" + @"
" + @" scrypt-pwgen {version}" + @"
" + @"" + @"

" + @" scrypt-pwgen is free software and the source code is available at " + @" here." + @"

" + @"

" + @" It makes use of the ObjFW " + @"framework and also uses its scrypt implementation." + @"

" + @"" + @""; + +@implementation AboutController +- (void)viewDidLoad +{ + self.automaticallyAdjustsScrollViewInsets = NO; + + NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; + NSString *version = infoDictionary[@"CFBundleShortVersionString"]; + NSString *aboutHTML = [aboutHTMLTemplate + stringByReplacingOccurrencesOfString: @"{version}" + withString: version]; + [self.webView loadHTMLString: aboutHTML + baseURL: nil]; +} + +- (void)dealloc +{ + [_webView release]; + + [super dealloc]; +} + +- (BOOL)webView: (UIWebView*)webView + shouldStartLoadWithRequest: (NSURLRequest*)request + navigationType: (UIWebViewNavigationType)navigationType +{ + if (navigationType == UIWebViewNavigationTypeLinkClicked) { + [[UIApplication sharedApplication] openURL: request.URL + options: @{} + completionHandler: ^ (BOOL success) { + }]; + return NO; + } + + return YES; +} +@end diff --git a/iOS/Base.lproj/Main.storyboard b/iOS/Base.lproj/Main.storyboard index 8040cf7..8cdfbcb 100644 --- a/iOS/Base.lproj/Main.storyboard +++ b/iOS/Base.lproj/Main.storyboard @@ -61,6 +61,11 @@ + + + + + @@ -76,6 +81,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -419,7 +460,7 @@ - + diff --git a/iOS/scrypt-pwgen.xcodeproj/project.pbxproj b/iOS/scrypt-pwgen.xcodeproj/project.pbxproj index 49402be..ee06269 100644 --- a/iOS/scrypt-pwgen.xcodeproj/project.pbxproj +++ b/iOS/scrypt-pwgen.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 4B2E52EA1DA942840040D091 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4B2E52E81DA942840040D091 /* Main.storyboard */; }; 4B2E52EC1DA942840040D091 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4B2E52EB1DA942840040D091 /* Assets.xcassets */; }; 4B2E52EF1DA942840040D091 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4B2E52ED1DA942840040D091 /* LaunchScreen.storyboard */; }; + 4B82D1151DAAAFCE00F32B2F /* AboutController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B82D1141DAAAFCE00F32B2F /* AboutController.m */; }; 4BA115D21DA9432D007ED4EA /* LegacyPasswordGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BA115CE1DA9432D007ED4EA /* LegacyPasswordGenerator.m */; settings = {COMPILER_FLAGS = "-fconstant-string-class=OFConstantString -fno-constant-cfstrings"; }; }; 4BA115D31DA9432D007ED4EA /* NewPasswordGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BA115D01DA9432D007ED4EA /* NewPasswordGenerator.m */; settings = {COMPILER_FLAGS = "-fconstant-string-class=OFConstantString -fno-constant-cfstrings"; }; }; 4BA115D61DA94390007ED4EA /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BA115D51DA94390007ED4EA /* UIKit.framework */; }; @@ -54,6 +55,8 @@ 4B2E52EB1DA942840040D091 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4B2E52EE1DA942840040D091 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 4B2E52F01DA942840040D091 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 4B82D1131DAAAFCE00F32B2F /* AboutController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AboutController.h; sourceTree = ""; }; + 4B82D1141DAAAFCE00F32B2F /* AboutController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AboutController.m; sourceTree = ""; }; 4BA115CD1DA9432D007ED4EA /* LegacyPasswordGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LegacyPasswordGenerator.h; path = ../LegacyPasswordGenerator.h; sourceTree = ""; }; 4BA115CE1DA9432D007ED4EA /* LegacyPasswordGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LegacyPasswordGenerator.m; path = ../LegacyPasswordGenerator.m; sourceTree = ""; }; 4BA115CF1DA9432D007ED4EA /* NewPasswordGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NewPasswordGenerator.h; path = ../NewPasswordGenerator.h; sourceTree = ""; }; @@ -106,6 +109,8 @@ isa = PBXGroup; children = ( 4B2E52EB1DA942840040D091 /* Assets.xcassets */, + 4B82D1131DAAAFCE00F32B2F /* AboutController.h */, + 4B82D1141DAAAFCE00F32B2F /* AboutController.m */, 4BB3CDFB1DA9764300FEE5ED /* AddSiteController.h */, 4BB3CDFC1DA9764300FEE5ED /* AddSiteController.m */, 4B2E52E21DA942840040D091 /* AppDelegate.h */, @@ -220,6 +225,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4B82D1151DAAAFCE00F32B2F /* AboutController.m in Sources */, 4BB3CDFD1DA9764300FEE5ED /* AddSiteController.m in Sources */, 4B2E52E41DA942840040D091 /* AppDelegate.m in Sources */, 4BA115D21DA9432D007ED4EA /* LegacyPasswordGenerator.m in Sources */,