Using custom NSNumberFormatter to prevent errors on validation.

This commit is contained in:
michael starke
2016-08-24 11:46:50 +02:00
parent 7755bc9b93
commit d776d1d8a0
6 changed files with 105 additions and 70 deletions

View File

@@ -130,6 +130,7 @@
4C63B8FB17A3154D0091BD72 /* MPContextToolbarButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C63B8FA17A3154D0091BD72 /* MPContextToolbarButton.m */; };
4C65C79C16DD283900E32CFF /* MPToolbarButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C65C79B16DD283900E32CFF /* MPToolbarButton.m */; };
4C65FAE916D16DDB006E0577 /* MPPasswordInputController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C65FAE716D16DDB006E0577 /* MPPasswordInputController.m */; };
4C663D411D6D91A900CB6237 /* MPNumberFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C663D401D6D91A900CB6237 /* MPNumberFormatter.m */; };
4C6AEEF91A043E2B00CA2420 /* MPDocumentController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C6AEEF81A043E2B00CA2420 /* MPDocumentController.m */; };
4C6AEF031A04400E00CA2420 /* OpenPanelAccessoryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C6AEF021A04400E00CA2420 /* OpenPanelAccessoryView.xib */; };
4C6B7C7D18BE7EB0001D5D77 /* MPDocument+HistoryBrowsing.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C6B7C7C18BE7EB0001D5D77 /* MPDocument+HistoryBrowsing.m */; };
@@ -469,6 +470,8 @@
4C65C79B16DD283900E32CFF /* MPToolbarButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPToolbarButton.m; sourceTree = "<group>"; };
4C65FAE616D16DDB006E0577 /* MPPasswordInputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPasswordInputController.h; sourceTree = "<group>"; };
4C65FAE716D16DDB006E0577 /* MPPasswordInputController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPasswordInputController.m; sourceTree = "<group>"; };
4C663D3F1D6D91A900CB6237 /* MPNumberFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPNumberFormatter.h; sourceTree = "<group>"; };
4C663D401D6D91A900CB6237 /* MPNumberFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPNumberFormatter.m; sourceTree = "<group>"; };
4C6AEEF71A043E2B00CA2420 /* MPDocumentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDocumentController.h; sourceTree = "<group>"; };
4C6AEEF81A043E2B00CA2420 /* MPDocumentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDocumentController.m; sourceTree = "<group>"; };
4C6AEF021A04400E00CA2420 /* OpenPanelAccessoryView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OpenPanelAccessoryView.xib; sourceTree = "<group>"; };
@@ -876,6 +879,8 @@
4C569D9D17652B0600595B62 /* MPConstants.m */,
4CCEDE2C179F2122008402BE /* MPNotifications.h */,
4CCEDE2D179F213B008402BE /* MPNotifications.m */,
4C663D3F1D6D91A900CB6237 /* MPNumberFormatter.h */,
4C663D401D6D91A900CB6237 /* MPNumberFormatter.m */,
);
name = Common;
sourceTree = "<group>";
@@ -1754,6 +1759,7 @@
4CC0D2CE17974A47000B4BDA /* MPCustomFieldTableViewDelegate.m in Sources */,
4CC0D2D117974A5A000B4BDA /* MPAttachmentTableViewDelegate.m in Sources */,
4C26C33F18D8C92100CF1A1C /* MPTemporaryFileStorage.m in Sources */,
4C663D411D6D91A900CB6237 /* MPNumberFormatter.m in Sources */,
4CD2B9061849424B0051B395 /* MPAutotypeContext.m in Sources */,
4CFB18E418A17FA20097A34B /* MPUpdateSettingsController.m in Sources */,
4C7B63771C0CB51F00D7038C /* TTTStringTransformers.m in Sources */,

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="9532" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
<capability name="box content view" minToolsVersion="7.0"/>
</dependencies>
<objects>
@@ -31,16 +31,16 @@
<rect key="frame" x="0.0" y="0.0" width="351" height="291"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="148">
<rect key="frame" x="18" y="253" width="66" height="17"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="148">
<rect key="frame" x="18" y="251" width="66" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Password:" id="149">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="152">
<rect key="frame" x="90" y="247" width="200" height="24"/>
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="152">
<rect key="frame" x="90" y="247" width="201" height="24"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="200" id="621"/>
</constraints>
@@ -50,8 +50,8 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<slider verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="173">
<rect key="frame" x="88" y="220" width="204" height="21"/>
<slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="173">
<rect key="frame" x="88" y="220" width="205" height="21"/>
<sliderCell key="cell" state="on" alignment="left" maxValue="100" doubleValue="50" tickMarkPosition="above" sliderType="linear" id="174"/>
</slider>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="178">
@@ -62,36 +62,34 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="182">
<rect key="frame" x="298" y="219" width="28" height="22"/>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="182">
<rect key="frame" x="299" y="219" width="32" height="22"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="28" id="eVc-Kg-bCi"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="32" id="eVc-Kg-bCi"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="183">
<numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="CNP-dv-vhg">
<real key="minimum" value="0.0"/>
</numberFormatter>
<customFormatter key="formatter" id="VRL-ed-DDG" customClass="MPNumberFormatter"/>
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<box autoresizesSubviews="NO" misplaced="YES" title="Allowed Characters" borderType="line" translatesAutoresizingMaskIntoConstraints="NO" id="332">
<rect key="frame" x="17" y="88" width="312" height="94"/>
<box autoresizesSubviews="NO" title="Allowed Characters" borderType="line" translatesAutoresizingMaskIntoConstraints="NO" id="332">
<rect key="frame" x="17" y="88" width="317" height="94"/>
<view key="contentView" id="f93-Su-hga">
<rect key="frame" x="1" y="1" width="310" height="78"/>
<rect key="frame" x="1" y="1" width="315" height="78"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="411">
<rect key="frame" x="18" y="19" width="274" height="22"/>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="411">
<rect key="frame" x="18" y="19" width="279" height="22"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="412" customClass="HNHUIRoundedTextFieldCell">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" misplaced="YES" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="452">
<rect key="frame" x="18" y="49" width="37" height="19"/>
<button verticalHuggingPriority="750" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="452">
<rect key="frame" x="18" y="49" width="36" height="19"/>
<buttonCell key="cell" type="roundRect" title="A-Z" bezelStyle="roundedRect" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="453">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
<font key="font" metaFont="cellTitle"/>
@@ -100,8 +98,8 @@
<action selector="_toggleCharacters:" target="-2" id="474"/>
</connections>
</button>
<button verticalHuggingPriority="750" misplaced="YES" tag="2" translatesAutoresizingMaskIntoConstraints="NO" id="456">
<rect key="frame" x="63" y="49" width="35" height="19"/>
<button verticalHuggingPriority="750" tag="2" translatesAutoresizingMaskIntoConstraints="NO" id="456">
<rect key="frame" x="62" y="49" width="33" height="19"/>
<buttonCell key="cell" type="roundRect" title="a-z" bezelStyle="roundedRect" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="457">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
<font key="font" metaFont="cellTitle"/>
@@ -110,8 +108,8 @@
<action selector="_toggleCharacters:" target="-2" id="475"/>
</connections>
</button>
<button verticalHuggingPriority="750" misplaced="YES" tag="4" translatesAutoresizingMaskIntoConstraints="NO" id="460">
<rect key="frame" x="106" y="49" width="37" height="19"/>
<button verticalHuggingPriority="750" tag="4" translatesAutoresizingMaskIntoConstraints="NO" id="460">
<rect key="frame" x="103" y="49" width="35" height="19"/>
<buttonCell key="cell" type="roundRect" title="0-9" bezelStyle="roundedRect" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="461">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
<font key="font" metaFont="cellTitle"/>
@@ -120,8 +118,8 @@
<action selector="_toggleCharacters:" target="-2" id="476"/>
</connections>
</button>
<button verticalHuggingPriority="750" misplaced="YES" tag="8" translatesAutoresizingMaskIntoConstraints="NO" id="464">
<rect key="frame" x="151" y="49" width="31" height="19"/>
<button verticalHuggingPriority="750" tag="8" translatesAutoresizingMaskIntoConstraints="NO" id="464">
<rect key="frame" x="146" y="49" width="32" height="19"/>
<buttonCell key="cell" type="roundRect" title="#!?" bezelStyle="roundedRect" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="465">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
<font key="font" metaFont="cellTitle"/>
@@ -130,8 +128,8 @@
<action selector="_toggleCharacters:" target="-2" id="477"/>
</connections>
</button>
<button verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="468">
<rect key="frame" x="190" y="49" width="59" height="19"/>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="468">
<rect key="frame" x="186" y="49" width="58" height="19"/>
<buttonCell key="cell" type="roundRect" title="Custom" bezelStyle="roundedRect" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="469">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
<font key="font" metaFont="cellTitle"/>
@@ -162,8 +160,8 @@
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</box>
<button verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="494">
<rect key="frame" x="227" y="18" width="99" height="25"/>
<button verticalHuggingPriority="750" horizontalCompressionResistancePriority="749" translatesAutoresizingMaskIntoConstraints="NO" id="494">
<rect key="frame" x="231" y="18" width="100" height="25"/>
<buttonCell key="cell" type="roundTextured" title="Use Password" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="495">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -172,15 +170,15 @@
<action selector="_usePassword:" target="-2" id="561"/>
</connections>
</button>
<button misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="500">
<rect key="frame" x="18" y="68" width="209" height="18"/>
<button translatesAutoresizingMaskIntoConstraints="NO" id="500">
<rect key="frame" x="18" y="68" width="204" height="18"/>
<buttonCell key="cell" type="check" title="Copy password to pasteboard" bezelStyle="regularSquare" imagePosition="left" inset="2" id="501">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="509">
<rect key="frame" x="298" y="247" width="28" height="25"/>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="509">
<rect key="frame" x="299" y="247" width="32" height="25"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSRefreshTemplate" imagePosition="only" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="510">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -189,8 +187,8 @@
<action selector="_generatePassword:" target="-2" id="600"/>
</connections>
</button>
<button verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="613">
<rect key="frame" x="163" y="18" width="56" height="25"/>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="613">
<rect key="frame" x="167" y="18" width="56" height="25"/>
<buttonCell key="cell" type="roundTextured" title="Cancel" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="614">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -199,8 +197,8 @@
<action selector="_cancel:" target="-2" id="623"/>
</connections>
</button>
<levelIndicator verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="635">
<rect key="frame" x="90" y="190" width="165" height="16"/>
<levelIndicator verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="635">
<rect key="frame" x="90" y="190" width="173" height="16"/>
<levelIndicatorCell key="cell" alignment="left" doubleValue="10" maxValue="90" warningValue="55" criticalValue="30" levelIndicatorStyle="continuousCapacity" id="636" customClass="HNHUILevelIndicatorCell"/>
</levelIndicator>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="646">
@@ -211,8 +209,8 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="652">
<rect key="frame" x="261" y="190" width="67" height="17"/>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="652">
<rect key="frame" x="269" y="190" width="64" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="25000 bit" id="653">
<numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="# bit" negativeFormat="# bit" usesGroupingSeparator="NO" paddingCharacter="*" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="309" decimalSeparator="," groupingSeparator="." currencyDecimalSeparator="," plusSign="+" minusSign="-" notANumberSymbol="NaN" perMillSymbol="‰" percentSymbol="%" exponentSymbol="E" positivePrefix="" positiveSuffix=" bit" negativePrefix="-" negativeSuffix=" bit" id="681"/>
<font key="font" metaFont="system"/>
@@ -220,8 +218,11 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yil-UB-jtO">
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yil-UB-jtO">
<rect key="frame" x="20" y="18" width="83" height="25"/>
<constraints>
<constraint firstAttribute="width" constant="83" id="b3N-Jq-46u"/>
</constraints>
<buttonCell key="cell" type="roundTextured" title="Set Default" bezelStyle="texturedRounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Wvs-Md-Ob8">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -230,8 +231,8 @@
</connections>
</buttonCell>
</button>
<button misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4yb-SC-vau">
<rect key="frame" x="18" y="48" width="237" height="18"/>
<button translatesAutoresizingMaskIntoConstraints="NO" id="4yb-SC-vau">
<rect key="frame" x="18" y="48" width="232" height="18"/>
<buttonCell key="cell" type="check" title="Use default only for selected entry" bezelStyle="regularSquare" imagePosition="left" inset="2" id="cfZ-5F-Nge">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@@ -270,7 +271,7 @@
<constraint firstItem="652" firstAttribute="leading" secondItem="635" secondAttribute="trailing" constant="8" symbolic="YES" id="672"/>
<constraint firstAttribute="trailing" secondItem="652" secondAttribute="trailing" constant="20" symbolic="YES" id="679"/>
<constraint firstItem="635" firstAttribute="leading" secondItem="152" secondAttribute="leading" id="680"/>
<constraint firstItem="613" firstAttribute="leading" secondItem="yil-UB-jtO" secondAttribute="trailing" constant="60" id="59d-1n-jSa"/>
<constraint firstItem="613" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="yil-UB-jtO" secondAttribute="trailing" constant="8" symbolic="YES" id="59d-1n-jSa"/>
<constraint firstItem="646" firstAttribute="trailing" secondItem="178" secondAttribute="trailing" id="6kR-jk-E8r"/>
<constraint firstItem="yil-UB-jtO" firstAttribute="leading" secondItem="500" secondAttribute="leading" id="Hic-qB-mt4"/>
<constraint firstItem="4yb-SC-vau" firstAttribute="top" secondItem="500" secondAttribute="bottom" constant="6" id="IZo-0q-BdQ"/>
@@ -282,7 +283,7 @@
<constraint firstItem="178" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="pAc-di-F68"/>
<constraint firstItem="500" firstAttribute="leading" secondItem="4yb-SC-vau" secondAttribute="leading" id="xv1-5v-Ljh"/>
</constraints>
<point key="canvasLocation" x="140" y="81.5"/>
<point key="canvasLocation" x="375.5" y="388.5"/>
</customView>
</objects>
<resources>

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="9059" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9059"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPPasswordInputController">
@@ -23,7 +23,6 @@
<subviews>
<button verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2">
<rect key="frame" x="320" y="64" width="83" height="32"/>
<animations/>
<buttonCell key="cell" type="push" title="Unlock" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="3">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -37,7 +36,6 @@ DQ
</button>
<textField verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="17">
<rect key="frame" x="115" y="112" width="46" height="17"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Keyfile" id="18">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -46,7 +44,6 @@ DQ
</textField>
<pathControl verticalHuggingPriority="750" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="241">
<rect key="frame" x="164" y="108" width="197" height="26"/>
<animations/>
<pathCell key="cell" selectable="YES" editable="YES" alignment="left" pathStyle="popUp" id="242">
<font key="font" metaFont="system"/>
</pathCell>
@@ -57,12 +54,10 @@ DQ
<constraint firstAttribute="height" constant="48" id="273"/>
<constraint firstAttribute="width" constant="48" id="456"/>
</constraints>
<animations/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="02_MessageBoxWarningTemplate" id="263"/>
</imageView>
<textField verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="268">
<rect key="frame" x="206" y="172" width="112" height="17"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Wrong password!" id="269">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -74,7 +69,6 @@ DQ
<constraints>
<constraint firstAttribute="width" constant="191" id="389"/>
</constraints>
<animations/>
<secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="Enter Password" drawsBackground="YES" usesSingleLineMode="YES" id="339">
<font key="font" size="13" name="Menlo-Regular"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
@@ -86,7 +80,6 @@ DQ
</secureTextField>
<button verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="408">
<rect key="frame" x="366" y="140" width="31" height="25"/>
<animations/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSQuickLookTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="409">
<behavior key="behavior" pushIn="YES" changeContents="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@@ -94,7 +87,6 @@ DQ
</button>
<button verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="486">
<rect key="frame" x="366" y="107" width="31" height="25"/>
<animations/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSStopProgressTemplate" imagePosition="only" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="487">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -105,7 +97,6 @@ DQ
</button>
<button misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="d8O-Ha-rrS">
<rect key="frame" x="81" y="143" width="80" height="18"/>
<animations/>
<buttonCell key="cell" type="check" title="Password" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="IU9-5u-jn9">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@@ -138,7 +129,6 @@ DQ
<constraint firstItem="d8O-Ha-rrS" firstAttribute="centerY" secondItem="338" secondAttribute="centerY" id="kgB-jV-OGy"/>
<constraint firstItem="d8O-Ha-rrS" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="vxq-YP-UhR"/>
</constraints>
<animations/>
</customView>
</objects>
<resources>

View File

@@ -268,7 +268,7 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
#pragma mark Popovers
- (IBAction)_popUpPasswordGenerator:(id)sender {
[self.generatePasswordButton setEnabled:NO];
self.generatePasswordButton.enabled = NO;
MPPasswordCreatorViewController *viewController = [[MPPasswordCreatorViewController alloc] init];
viewController.allowsEntryDefaults = YES;
viewController.representedObject = self.representedObject;
@@ -292,17 +292,6 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
[_activePopover showRelativeToRect:NSZeroRect ofView:view preferredEdge:edge];
}
- (BOOL)popoverShouldClose:(NSPopover *)popover {
/* See http://stackoverflow.com/a/34215887/353268
* PasswordCreator uses a NSNumberFormatter to validate the input.
* If the user types something that's not a number it will open a
* dialog, which would cause the popover to close and MacPass to crash.
*
* This stops the popover to close when the dialog is active.
*/
return ![popover.contentViewController.view.window makeFirstResponder:popover];
}
- (void)popoverDidClose:(NSNotification *)notification {
/* We do not enable the button all the time, but it's working find this way */
[self.generatePasswordButton setEnabled:YES];

View File

@@ -0,0 +1,16 @@
//
// MPNumberFormatter.h
// MacPass
//
// Created by Michael Starke on 24/08/16.
// Copyright © 2016 HicknHack Software GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
* A variation of NSNumberFormatter, that always supplies a valid value. Ideal for usage in NSPopover
*/
@interface MPNumberFormatter : NSNumberFormatter
@end

View File

@@ -0,0 +1,33 @@
//
// MPNumberFormatter.m
// MacPass
//
// Created by Michael Starke on 24/08/16.
// Copyright © 2016 HicknHack Software GmbH. All rights reserved.
//
#import "MPNumberFormatter.h"
@implementation MPNumberFormatter
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
self.minimum = [NSDecimalNumber one];
self.formatterBehavior = NSNumberFormatterBehavior10_4;
self.allowsFloats = NO;
self.alwaysShowsDecimalSeparator = NO;
return self;
}
- (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error {
/* If super can pase without an error, all is fine */
if([super getObjectValue:obj forString:string errorDescription:error]) {
return YES;
}
/* TODO adhere to minimum/maxiumum? */
*obj = [self.minimum copy];
return YES;
}
@end