-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMLAbout.m
134 lines (111 loc) · 5.9 KB
/
MLAbout.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
Copyright (c) 2017 Max Lungarella <cybrmx@gmail.com>
Created on 27/07/2017.
This file is part of AmiKo for OSX.
AmiKo for OSX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------ */
#import "MLAbout.h"
#import "MLUtilities.h"
@implementation MLAbout
+ (void) showReportFile
{
// A. Check first users documents folder
NSFileManager *fileManager = [NSFileManager defaultManager];
// Get documents directory
NSString *documentsDir = [MLUtilities documentsDirectory];
if ([MLUtilities isGermanApp]) {
NSString *filePath = [[documentsDir stringByAppendingPathComponent:@"amiko_report_de"] stringByAppendingPathExtension:@"html"];
if ([fileManager fileExistsAtPath:filePath]) {
// Starts Safari
[[NSWorkspace sharedWorkspace] openFile:filePath];
} else {
NSURL *aboutFile = [[NSBundle mainBundle] URLForResource:@"amiko_report_de" withExtension:@"html"];
// Starts Safari
[[NSWorkspace sharedWorkspace] openURL:aboutFile];
}
} else if ([MLUtilities isFrenchApp]) {
NSString *filePath = [[documentsDir stringByAppendingPathComponent:@"amiko_report_fr"] stringByAppendingPathExtension:@"html"];
if ([fileManager fileExistsAtPath:filePath]) {
// Starts Safari
[[NSWorkspace sharedWorkspace] openFile:filePath];
} else {
NSURL *aboutFile = [[NSBundle mainBundle] URLForResource:@"amiko_report_fr" withExtension:@"html"];
// Starts Safari
[[NSWorkspace sharedWorkspace] openURL:aboutFile];
}
}
}
+ (void) showAboutPanel
{
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *creditsPath = [mainBundle pathForResource:@"Credits" ofType:@"rtf"]; // localized
NSAttributedString *credits = [[NSAttributedString alloc] initWithPath:creditsPath documentAttributes:nil];
NSDate *today = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd.MM.yyyy"];
NSString *compileDate = [dateFormat stringFromDate:today];
NSString *versionString = [NSString stringWithFormat:@"%@", compileDate];
NSDictionary *optionsDict = [NSDictionary dictionaryWithObjectsAndKeys:
credits, @"Credits",
[mainBundle objectForInfoDictionaryKey:@"CFBundleName"], @"ApplicationName",
[mainBundle objectForInfoDictionaryKey:@"NSHumanReadableCopyright"], @"Copyright",
[mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"ApplicationVersion",
versionString, @"Version",
nil];
[NSApp orderFrontStandardAboutPanelWithOptions:optionsDict];
}
+ (void) sendFeedback
{
NSString *subject = [NSString stringWithFormat:@"%@ Feedback", APP_NAME];
NSString *encodedSubject = [NSString stringWithFormat:@"mailto:zdavatz@ywesee.com?subject=%@", [subject stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSURL *helpFile = [NSURL URLWithString:encodedSubject];
// Starts mail client
[[NSWorkspace sharedWorkspace] openURL:helpFile];
}
+ (void) shareApp
{
// Starts mail client
NSString* subject = [NSString stringWithFormat:@"%@ OS X", APP_NAME];
NSString* body = nil;
if ([MLUtilities isGermanApp])
body = [NSString stringWithFormat:@"%@ OS X: Schweizer Arzneimittelkompendium\r\n\n"
"Get it now: https://itunes.apple.com/us/app/amiko/id%@?mt=12\r\n\nEnjoy!\r\n", APP_NAME, APP_ID];
else if ([MLUtilities isFrenchApp])
body = [NSString stringWithFormat:@"%@ OS X: Compendium des Médicaments Suisse\r\n\n"
"Get it now: https://itunes.apple.com/us/app/amiko/id%@?mt=12\r\n\nEnjoy!\r\n", APP_NAME, APP_ID];
NSString *encodedSubject = [NSString stringWithFormat:@"subject=%@", [subject stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *encodedBody = [NSString stringWithFormat:@"body=%@", [body stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *encodedURLString = [NSString stringWithFormat:@"mailto:?%@&%@", encodedSubject, encodedBody];
NSURL *mailtoURL = [NSURL URLWithString:encodedURLString];
[[NSWorkspace sharedWorkspace] openURL:mailtoURL];
}
+ (void) rateApp
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"macappstore://itunes.apple.com/app/id%@?mt=12", APP_ID]]];
}
+ (void) showHelp
{
// Starts Safari
if ([[MLUtilities appOwner] isEqualToString:@"zurrose"]) {
NSURL *helpFile = [NSURL URLWithString:@"http://www.zurrose.ch/amiko"];
[[NSWorkspace sharedWorkspace] openURL:helpFile];
}
else if ([[MLUtilities appOwner] isEqualToString:@"ywesee"]) {
NSURL *helpFile = [NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/us/app/amiko/id%@?mt=12", APP_ID]];
[[NSWorkspace sharedWorkspace] openURL:helpFile];
}
else if ([[MLUtilities appOwner] isEqualToString:@"desitin"]) {
NSURL *helpFile = [NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/us/app/amiko/id%@?mt=12", APP_ID]];
[[NSWorkspace sharedWorkspace] openURL:helpFile];
}
}
@end