Use properties.
This commit is contained in:
1 parent
d27b3456cd
commit
ff5bc58b4c
1 file changed
+12
-12
+12
-12
@@ -105,33 +105,33 @@
|
|||||||
{
|
{
|
||||||
BOOL firstLaunch = YES;
|
BOOL firstLaunch = YES;
|
||||||
|
|
||||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"]) {
|
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"SBFirstLaunch"]) {
|
||||||
firstLaunch = NO;
|
firstLaunch = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"WarningDonate"]) {
|
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"SBWarningDonate"]) {
|
||||||
NSDate *lastDonateDate = [[NSUserDefaults standardUserDefaults] valueForKey:@"DonateAskDate"];
|
NSDate *lastDonateDate = [[NSUserDefaults standardUserDefaults] valueForKey:@"SBDonateAskDate"];
|
||||||
const BOOL timePassed = !lastDonateDate || (-1 * lastDonateDate.timeIntervalSinceNow) >= DONATE_NAG_TIME;
|
const BOOL timePassed = !lastDonateDate || (-1 * lastDonateDate.timeIntervalSinceNow) >= DONATE_NAG_TIME;
|
||||||
|
|
||||||
if (!firstLaunch && timePassed) {
|
if (!firstLaunch && timePassed) {
|
||||||
[[NSUserDefaults standardUserDefaults] setValue:[NSDate date] forKey:@"DonateAskDate"];
|
[[NSUserDefaults standardUserDefaults] setValue:[NSDate date] forKey:@"SBDonateAskDate"];
|
||||||
|
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
[alert setMessageText: NSLocalizedString(@"Support Subler", "Donation -> title")];
|
alert.messageText = NSLocalizedString(@"Support Subler", "Donation -> title");
|
||||||
|
|
||||||
NSString *donateMessage = [NSString stringWithFormat: @"%@",
|
NSString *donateMessage = [NSString stringWithFormat: @"%@",
|
||||||
NSLocalizedString(@" A lot of time and effort have gone into development, coding, and refinement."
|
NSLocalizedString(@" A lot of time and effort have gone into development, coding, and refinement."
|
||||||
" If you enjoy using it, please consider showing your appreciation with a donation.", "Donation -> message")];
|
" If you enjoy using it, please consider showing your appreciation with a donation.", "Donation -> message")];
|
||||||
|
|
||||||
[alert setInformativeText:donateMessage];
|
alert.informativeText = donateMessage;
|
||||||
[alert setAlertStyle: NSAlertStyleInformational];
|
alert.alertStyle = NSAlertStyleInformational;
|
||||||
|
|
||||||
[alert addButtonWithTitle: NSLocalizedString(@"Donate", "Donation -> button")];
|
[alert addButtonWithTitle: NSLocalizedString(@"Donate", "Donation -> button")];
|
||||||
NSButton *noDonateButton = [alert addButtonWithTitle: NSLocalizedString(@"Nope", "Donation -> button")];
|
NSButton *noDonateButton = [alert addButtonWithTitle: NSLocalizedString(@"Nope", "Donation -> button")];
|
||||||
[noDonateButton setKeyEquivalent:[NSString stringWithFormat:@"%c", 0x1B]]; //escape key
|
noDonateButton.keyEquivalent = [NSString stringWithFormat:@"%c", 0x1B]; //escape key
|
||||||
|
|
||||||
const BOOL allowNeverAgain = lastDonateDate != nil; //hide the "don't show again" check the first time - give them time to try the app
|
const BOOL allowNeverAgain = lastDonateDate != nil; //hide the "don't show again" check the first time - give them time to try the app
|
||||||
[alert setShowsSuppressionButton:allowNeverAgain];
|
alert.showsSuppressionButton = allowNeverAgain;
|
||||||
if (allowNeverAgain) {
|
if (allowNeverAgain) {
|
||||||
[[alert suppressionButton] setTitle:NSLocalizedString(@"Don't ask me about this ever again.", "Donation -> button")];
|
[[alert suppressionButton] setTitle:NSLocalizedString(@"Don't ask me about this ever again.", "Donation -> button")];
|
||||||
}
|
}
|
||||||
@@ -142,13 +142,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allowNeverAgain) {
|
if (allowNeverAgain) {
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:([[alert suppressionButton] state] != NSOnState) forKey:@"WarningDonate"];
|
[[NSUserDefaults standardUserDefaults] setBool:(alert.suppressionButton.state != NSOnState) forKey:@"SBWarningDonate"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstLaunch) {
|
if (firstLaunch) {
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FirstLaunch"];
|
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"SBFirstLaunch"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[SBQueueController sharedManager];
|
[SBQueueController sharedManager];
|
||||||
@@ -195,7 +195,7 @@
|
|||||||
|
|
||||||
- (IBAction) linkDonate:(id)sender
|
- (IBAction) linkDonate:(id)sender
|
||||||
{
|
{
|
||||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://subler.org/donate.html"]];
|
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://subler.org/donate.php"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in new issue
Block a user