Merge branch 'disable_sparkle_on_debug'

This commit is contained in:
michael starke
2016-03-17 17:37:53 +01:00
7 changed files with 67 additions and 39 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -26,7 +26,7 @@
<menuItem title="Check for Updates…" id="zMO-8r-g5v">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="checkForUpdates:" target="EpI-0u-HQc" id="W42-xA-Wj6"/>
<action selector="checkForUpdates:" target="494" id="5dV-gw-yHT"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="236">
@@ -320,6 +320,5 @@
</connections>
</customObject>
<customObject id="420" customClass="NSFontManager"/>
<customObject id="EpI-0u-HQc" customClass="SUUpdater"/>
</objects>
</document>

View File

@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPUpdateSettingsController">
<connections>
<outlet property="automaticallyCheckForUpdatesCheckButton" destination="Z6x-oU-NC5" id="xHU-Lt-PmA"/>
<outlet property="checkIntervallPopupButton" destination="pWJ-eJ-MBf" id="znu-Me-2Me"/>
<outlet property="view" destination="1" id="0Ig-r5-x8L"/>
</connections>
</customObject>
@@ -24,9 +26,6 @@
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="Tm5-i7-V4P" name="value" keyPath="automaticallyChecksForUpdates" id="8wg-xJ-C1I"/>
</connections>
</button>
<popUpButton verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pWJ-eJ-MBf">
<rect key="frame" x="145" y="17" width="112" height="26"/>
@@ -44,10 +43,6 @@
</items>
</menu>
</popUpButtonCell>
<connections>
<binding destination="Tm5-i7-V4P" name="enabled" keyPath="automaticallyChecksForUpdates" id="Ctn-0w-mKO"/>
<binding destination="Tm5-i7-V4P" name="selectedTag" keyPath="updateCheckInterval" id="N5f-FS-bbr"/>
</connections>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ckg-9t-MDS">
<rect key="frame" x="21" y="23" width="120" height="17"/>
@@ -69,7 +64,7 @@
<constraint firstItem="ckg-9t-MDS" firstAttribute="baseline" secondItem="pWJ-eJ-MBf" secondAttribute="baseline" id="ozZ-bW-f7y"/>
<constraint firstAttribute="bottom" secondItem="pWJ-eJ-MBf" secondAttribute="bottom" constant="20" symbolic="YES" id="pHW-e8-EU6"/>
</constraints>
<point key="canvasLocation" x="504" y="511.5"/>
</customView>
<customObject id="Tm5-i7-V4P" customClass="SUUpdater"/>
</objects>
</document>

View File

@@ -34,6 +34,7 @@ APPKIT_EXTERN NSString *const MPDidChangeStoredKeyFilesSettings;
@property (nonatomic, assign) BOOL isAllowedToStoreKeyFile;
- (IBAction)checkForUpdates:(id)sender;
- (IBAction)showPreferences:(id)sender;
- (IBAction)showPasswordCreator:(id)sender;
- (IBAction)createNewDatabase:(id)sender;

View File

@@ -36,8 +36,12 @@
#import "MPTemporaryFileStorageCenter.h"
#import "MPValueTransformerHelper.h"
#import "NSApplication+MPAdditions.h"
#import "KeePassKit/KeePassKit.h"
#import <Sparkle/Sparkle.h>
NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDidChangeStoredKeyFilesSettings";
@interface MPAppDelegate () {
@@ -93,7 +97,7 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
- (void)awakeFromNib {
_isAllowedToStoreKeyFile = NO;
/* Update the at the save menu */
[[self.saveMenuItem menu] setDelegate:self];
self.saveMenuItem.menu.delegate = self;
/* We want to inform anyone about the changes to keyFile remembering */
[self bind:NSStringFromSelector(@selector(isAllowedToStoreKeyFile))
@@ -158,6 +162,10 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
[MPAutotypeDaemon defaultDaemon];
/* Create Plugin Manager */
[MPPluginManager sharedManager];
#ifndef DEBUG
/* Only enable updater in Release */
[SUUpdater sharedUpdater];
#endif
}
#pragma mark -
@@ -221,9 +229,19 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
}
- (void)showHelp:(id)sender {
/* TODO: use Info.plist for URL */
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/mstarke/MacPass"]];
}
- (void)checkForUpdates:(id)sender {
#ifdef DEBUG
NSAlert *alert = [NSAlert alertWithMessageText:@"Updates are disabled!" defaultButton:@"Ok" alternateButton:nil otherButton:nil informativeTextWithFormat:@"Sparkle updates are only available in offical releases of %@!", NSApp.applicationName];
[alert runModal];
#else
[[SUUpdater sharedUpdater] checkForUpdates:sender];
#endif
}
#pragma mark -
#pragma mark Private Helper
- (void)_applicationDidFinishRestoringWindows:(NSNotification *)notification {

View File

@@ -39,23 +39,23 @@ typedef NS_ENUM(NSUInteger, MPDatePreset) {
NSArray *dateItems = @[ NSLocalizedString(@"TOMORROW", ""), NSLocalizedString(@"ONE_WEEK", ""), NSLocalizedString(@"ONE_MONTH", ""), NSLocalizedString(@"90_DAYS", ""), NSLocalizedString(@"ONE_YEAR", "") ];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"SELECT_DATE_PRESET", "") action:NULL keyEquivalent:@""];
[item setTag:MPDatePresetNone];
item.tag = MPDatePresetNone;
[presetMenu addItem:item];
[presetMenu addItem:[NSMenuItem separatorItem]];
for(NSInteger iIndex = 0; iIndex < sizeof(tags)/sizeof(NSUInteger); iIndex++) {
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:dateItems[iIndex] action:NULL keyEquivalent:@""];
[item setTag:tags[iIndex]];
item.tag = tags[iIndex];
[presetMenu addItem:item];
}
[self.datePicker setDateValue:[NSDate date]];
[self.presetPopupButton setMenu:presetMenu];
self.datePicker.dateValue = [NSDate date];
self.presetPopupButton.menu = presetMenu;
}
- (IBAction)useDate:(id)sender {
self.didCancel = NO;
self.date = [self.datePicker dateValue];
self.date = self.datePicker.dateValue;
[self.popover performClose:self];
}
@@ -65,32 +65,32 @@ typedef NS_ENUM(NSUInteger, MPDatePreset) {
}
- (IBAction)setDatePreset:(id)sender {
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
MPDatePreset preset = [[sender selectedItem] tag];
MPDatePreset preset = ((NSPopUpButton *)sender).selectedTag;
switch(preset) {
case MPDatePresetTomorrow:
[offsetComponents setDay:1];
offsetComponents.day = 1;
break;
case MPDatePresetOneWeek:
[offsetComponents setWeek:1];
offsetComponents.weekOfMonth = 1;
break;
case MPDatePresetOneMonth:
[offsetComponents setMonth:1];
offsetComponents.month = 1;
break;
case MPDatePreset90Days:
[offsetComponents setDay:90];
offsetComponents.day = 90;
break;
case MPDatePresetOneYear:
[offsetComponents setYear:1];
offsetComponents.year = 1;
break;
case MPDatePresetNone:
default:
return; // Nothing to do;
}
NSDate *newDate = [gregorian dateByAddingComponents:offsetComponents toDate:[NSDate date] options:0];
[self.datePicker setDateValue:newDate];
self.datePicker.dateValue = newDate;
}
@end

View File

@@ -7,8 +7,11 @@
//
#import "MPUpdateSettingsController.h"
#import <Sparkle/Sparkle.h>
@interface MPUpdateSettingsController ()
@property (weak) IBOutlet NSButton *automaticallyCheckForUpdatesCheckButton;
@property (weak) IBOutlet NSPopUpButton *checkIntervallPopupButton;
@end
@@ -30,4 +33,17 @@
return NSLocalizedString(@"UPDATE_SETTINGS", @"Update Settings Label");
}
- (void)awakeFromNib {
/* only enable bindings to settings in release mode */
#ifdef DEBUG
self.checkIntervallPopupButton.enabled = NO;
self.automaticallyCheckForUpdatesCheckButton.enabled = NO;
#else
[self.checkIntervallPopupButton bind:NSSelectedTagBinding toObject:[SUUpdater sharedUpdater] withKeyPath:NSStringFromSelector(@selector(updateCheckInterval)) options:nil];
[self.checkIntervallPopupButton bind:NSEnabledBinding toObject:[SUUpdater sharedUpdater] withKeyPath:NSStringFromSelector(@selector(automaticallyChecksForUpdates)) options:nil];
[self.automaticallyCheckForUpdatesCheckButton bind:NSValueBinding toObject:[SUUpdater sharedUpdater] withKeyPath:NSStringFromSelector(@selector(automaticallyChecksForUpdates)) options:nil];
#endif
}
@end

View File

@@ -15,15 +15,15 @@
}
- (NSString *)humanized {
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [calendar components:NSMinuteCalendarUnit|NSHourCalendarUnit|NSDayCalendarUnit|NSWeekCalendarUnit|NSMonthCalendarUnit fromDate:self toDate:[NSDate date] options:0];
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *components = [calendar components:NSCalendarUnitMinute|NSCalendarUnitHour|NSCalendarUnitDay|NSCalendarUnitWeekOfMonth|NSCalendarUnitMonth fromDate:self toDate:[NSDate date] options:0];
/* More than one month in the past, give full date */
if([components month] > 1) {
if(components.month > 1) {
return [NSDateFormatter localizedStringFromDate:self
dateStyle:NSDateFormatterShortStyle
timeStyle:NSDateFormatterShortStyle];
}
NSUInteger weeks = [components week];
NSUInteger weeks = components.weekOfMonth;
/* More than one week, less than a month */
if(weeks > 1) {
NSString *weekTemplate = NSLocalizedString(@"%ld_WEEKS_AGO", "% Weeks ago");
@@ -34,7 +34,7 @@
return NSLocalizedString(@"ONE_WEEK_AGO", "one week ago");
}
/* Last week */
NSUInteger days = [components day];
NSUInteger days = components.day;
if(days > 3) {
return NSLocalizedString(@"LAST_WEEK", "last week");
}
@@ -48,14 +48,13 @@
return NSLocalizedString(@"YESTERDAY", "Yesterday");
}
/* Hours ago */
if([components hour] > 1) {
if(components.hour > 1) {
NSString *hourTemplate = NSLocalizedString(@"%ld_HOURS_AGO", "% Hours ago");
return [NSString stringWithFormat:hourTemplate, [components hour]];
return [NSString stringWithFormat:hourTemplate, components.hour];
}
NSInteger minutes = [components minute];
if(minutes > 1) {
if(components.minute > 1) {
NSString *minuteTemplate = NSLocalizedString(@"%ld_MINUTES_AGO", "% Minutes ago");
return [NSString stringWithFormat:minuteTemplate, minutes];
return [NSString stringWithFormat:minuteTemplate, components.minute];
}
return NSLocalizedString(@"JUST_NOW", "Just now");
}