contacts: create or update contacts

Add ability to create a new contact with an unknow uri, or link it to an
existing contact.
This is presented in a popover, either from an history entry, or during
a call with an unknown URI.

Issue: #78236
Change-Id: I22fa416b9f5c7a6eceb6f2ea47bb30aa251cda54
diff --git a/ui/PersonLinker.xib b/ui/PersonLinker.xib
new file mode 100644
index 0000000..6ee92aa
--- /dev/null
+++ b/ui/PersonLinker.xib
@@ -0,0 +1,218 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="PersonLinkerVC">
+            <connections>
+                <outlet property="categoryComboBox" destination="MFf-kv-pz3" id="a2g-cf-dcv"/>
+                <outlet property="contactMethodLabel" destination="8pP-Sy-Vkd" id="UGZ-bY-lDO"/>
+                <outlet property="createContactSubview" destination="6M0-sm-haN" id="Ba5-9R-6fh"/>
+                <outlet property="createNewContactButton" destination="N0T-7S-TCW" id="MUz-ox-g0t"/>
+                <outlet property="firstNameField" destination="m4N-gI-w8E" id="qeh-cD-nEA"/>
+                <outlet property="lastNameField" destination="j0A-7O-Bvj" id="CcY-4A-Epn"/>
+                <outlet property="linkToExistingSubview" destination="4Dh-2q-0Sm" id="CMO-kR-mHc"/>
+                <outlet property="personsView" destination="eKe-7i-c79" id="oAv-Y3-gon"/>
+                <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
+            </connections>
+        </customObject>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <customView id="Hz6-mo-xeY">
+            <rect key="frame" x="0.0" y="1" width="308" height="452"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+            <subviews>
+                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8pP-Sy-Vkd">
+                    <rect key="frame" x="18" y="415" width="184" height="22"/>
+                    <textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" sendsActionOnEndEditing="YES" alignment="right" title="Contact Method" usesSingleLineMode="YES" id="a9R-r5-K3w">
+                        <font key="font" size="18" name="HelveticaNeue-Thin"/>
+                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                </textField>
+                <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4Dh-2q-0Sm">
+                    <rect key="frame" x="0.0" y="-21" width="308" height="428"/>
+                    <subviews>
+                        <scrollView fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="42" horizontalPageScroll="10" verticalLineScroll="42" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" scrollerKnobStyle="light" translatesAutoresizingMaskIntoConstraints="NO" id="sue-LK-DlA">
+                            <rect key="frame" x="0.0" y="61" width="308" height="337"/>
+                            <clipView key="contentView" misplaced="YES" id="bpD-gC-mEn">
+                                <rect key="frame" x="1" y="17" width="238" height="117"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                <subviews>
+                                    <outlineView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowHeight="40" indentationPerLevel="16" autoresizesOutlineColumn="YES" outlineTableColumn="eFy-j5-uaG" id="eKe-7i-c79">
+                                        <rect key="frame" x="0.0" y="0.0" width="238" height="42"/>
+                                        <autoresizingMask key="autoresizingMask"/>
+                                        <size key="intercellSpacing" width="3" height="2"/>
+                                        <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                        <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
+                                        <tableColumns>
+                                            <tableColumn identifier="NameColumn" width="303" minWidth="40" maxWidth="1000" id="eFy-j5-uaG">
+                                                <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
+                                                    <font key="font" metaFont="system"/>
+                                                    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+                                                    <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
+                                                </tableHeaderCell>
+                                                <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="2uY-eS-Evg" customClass="PersonCell">
+                                                    <font key="font" metaFont="system"/>
+                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                                    <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                </textFieldCell>
+                                                <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+                                            </tableColumn>
+                                        </tableColumns>
+                                        <connections>
+                                            <outlet property="delegate" destination="-2" id="4Ls-yd-9gL"/>
+                                            <outlet property="nextKeyView" destination="cfj-u3-ErF" id="oex-MO-dfb"/>
+                                        </connections>
+                                    </outlineView>
+                                </subviews>
+                                <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+                            </clipView>
+                            <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="4Sk-mY-PsD">
+                                <rect key="frame" x="1" y="117.99886953830719" width="238" height="16"/>
+                                <autoresizingMask key="autoresizingMask"/>
+                            </scroller>
+                            <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="awN-qf-qb2">
+                                <rect key="frame" x="224" y="17" width="15" height="102"/>
+                                <autoresizingMask key="autoresizingMask"/>
+                            </scroller>
+                        </scrollView>
+                        <searchField wantsLayer="YES" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZJY-k3-gHh">
+                            <rect key="frame" x="30" y="406" width="249" height="22"/>
+                            <searchFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" usesSingleLineMode="YES" bezelStyle="round" sendsSearchStringImmediately="YES" id="sS1-2Z-ZWi">
+                                <font key="font" metaFont="system"/>
+                                <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+                            </searchFieldCell>
+                            <connections>
+                                <outlet property="delegate" destination="-2" id="XVp-Zj-wcV"/>
+                                <outlet property="nextKeyView" destination="eKe-7i-c79" id="7Oc-g3-Xrb"/>
+                            </connections>
+                        </searchField>
+                        <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cfj-u3-ErF">
+                            <rect key="frame" x="9" y="24" width="291" height="30"/>
+                            <buttonCell key="cell" type="squareTextured" title="Add new contact" bezelStyle="texturedSquare" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="had-9Y-eza">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="presentNewContactForm:" target="-2" id="GOU-Lc-s5y"/>
+                                <outlet property="nextKeyView" destination="MFf-kv-pz3" id="ptg-Li-e6T"/>
+                            </connections>
+                        </button>
+                    </subviews>
+                </customView>
+                <comboBox verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MFf-kv-pz3">
+                    <rect key="frame" x="208" y="415" width="84" height="26"/>
+                    <comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" usesDataSource="YES" numberOfVisibleItems="5" id="Msw-lx-k0J">
+                        <font key="font" metaFont="system"/>
+                        <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                    </comboBoxCell>
+                    <connections>
+                        <outlet property="dataSource" destination="-2" id="tJu-f2-MiR"/>
+                        <outlet property="delegate" destination="-2" id="WaI-jK-1gz"/>
+                        <outlet property="nextKeyView" destination="ZJY-k3-gHh" id="tEx-0T-BlC"/>
+                    </connections>
+                </comboBox>
+            </subviews>
+            <point key="canvasLocation" x="578" y="354"/>
+        </customView>
+        <customView wantsLayer="YES" id="6M0-sm-haN">
+            <rect key="frame" x="0.0" y="5" width="269" height="216"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+            <subviews>
+                <textField verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="m4N-gI-w8E">
+                    <rect key="frame" x="12" y="112" width="245" height="27"/>
+                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="First name..." drawsBackground="YES" id="vyb-95-XaF">
+                        <font key="font" metaFont="system"/>
+                        <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                    <connections>
+                        <outlet property="delegate" destination="-2" id="CCw-aR-pcT"/>
+                        <outlet property="nextKeyView" destination="j0A-7O-Bvj" id="Ub8-NO-TRg"/>
+                    </connections>
+                </textField>
+                <textField verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="j0A-7O-Bvj">
+                    <rect key="frame" x="12" y="75" width="245" height="27"/>
+                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="Last name..." drawsBackground="YES" id="cGT-nu-sPa">
+                        <font key="font" metaFont="system"/>
+                        <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                    <connections>
+                        <outlet property="delegate" destination="-2" id="C7b-2i-RVK"/>
+                        <outlet property="nextKeyView" destination="N0T-7S-TCW" id="DHp-cl-011"/>
+                    </connections>
+                </textField>
+                <textField wantsLayer="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GgO-mM-nnz">
+                    <rect key="frame" x="24" y="186" width="221" height="30"/>
+                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="New Contact" id="v7b-de-MVd">
+                        <font key="font" metaFont="system" size="20"/>
+                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                </textField>
+                <scrollView ambiguous="YES" misplaced="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vzn-cW-Vtm">
+                    <rect key="frame" x="26" y="146" width="217" height="32"/>
+                    <clipView key="contentView" ambiguous="YES" misplaced="YES" drawsBackground="NO" copiesOnScroll="NO" id="2yu-GN-mus">
+                        <rect key="frame" x="1" y="1" width="223" height="133"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <textView ambiguous="YES" editable="NO" selectable="NO" drawsBackground="NO" importsGraphics="NO" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" usesFontPanel="YES" verticallyResizable="YES" allowsNonContiguousLayout="YES" quoteSubstitution="YES" dashSubstitution="YES" spellingCorrection="YES" smartInsertDelete="YES" id="TQq-By-akw">
+                                <rect key="frame" x="0.0" y="0.0" width="223" height="133"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                <size key="minSize" width="217" height="32"/>
+                                <size key="maxSize" width="463" height="10000000"/>
+                                <attributedString key="textStorage">
+                                    <fragment content="This contact will be added to your iCloud contacts ">
+                                        <attributes>
+                                            <font key="NSFont" metaFont="smallSystem"/>
+                                            <paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
+                                        </attributes>
+                                    </fragment>
+                                </attributedString>
+                                <color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                <size key="minSize" width="217" height="32"/>
+                                <size key="maxSize" width="463" height="10000000"/>
+                            </textView>
+                        </subviews>
+                        <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+                    </clipView>
+                    <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="XUh-Co-vZc">
+                        <rect key="frame" x="-100" y="-100" width="87" height="18"/>
+                        <autoresizingMask key="autoresizingMask"/>
+                    </scroller>
+                    <scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="C83-CS-odD">
+                        <rect key="frame" x="224" y="1" width="15" height="133"/>
+                        <autoresizingMask key="autoresizingMask"/>
+                    </scroller>
+                </scrollView>
+                <button verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="N0T-7S-TCW">
+                    <rect key="frame" x="12" y="38" width="245" height="30"/>
+                    <buttonCell key="cell" type="squareTextured" title="Create" bezelStyle="texturedSquare" alignment="center" enabled="NO" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="qZc-Z2-TpP">
+                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                        <font key="font" metaFont="system"/>
+                    </buttonCell>
+                    <connections>
+                        <action selector="createContact:" target="-2" id="zAV-BX-EwU"/>
+                        <outlet property="nextKeyView" destination="m4N-gI-w8E" id="Q27-eZ-3aK"/>
+                    </connections>
+                </button>
+            </subviews>
+            <constraints>
+                <constraint firstAttribute="centerX" secondItem="m4N-gI-w8E" secondAttribute="centerX" id="4IS-12-aeP"/>
+                <constraint firstAttribute="trailing" secondItem="N0T-7S-TCW" secondAttribute="trailing" constant="12" id="C3n-ql-y7T"/>
+                <constraint firstAttribute="centerX" secondItem="j0A-7O-Bvj" secondAttribute="centerX" id="JAP-Mr-JWl"/>
+                <constraint firstAttribute="bottom" secondItem="N0T-7S-TCW" secondAttribute="bottom" constant="40" id="WLz-RD-syK"/>
+                <constraint firstAttribute="centerX" secondItem="vzn-cW-Vtm" secondAttribute="centerX" id="ltD-l2-ESu"/>
+                <constraint firstItem="N0T-7S-TCW" firstAttribute="leading" secondItem="6M0-sm-haN" secondAttribute="leading" constant="12" id="xWn-BX-TdQ"/>
+                <constraint firstAttribute="centerX" secondItem="GgO-mM-nnz" secondAttribute="centerX" id="zLf-OH-9nF"/>
+            </constraints>
+            <point key="canvasLocation" x="949.5" y="317"/>
+        </customView>
+    </objects>
+</document>