Commit e5613be2 authored by Aral Balkan's avatar Aral Balkan

Progress towards #28: implementing accessibility on first step of the setup process.

parent c26e672d
......@@ -39,6 +39,8 @@
A78DAE8D1A800177009FDB15 /* ProfileImageComponentControlPanelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A78DAE8B1A800177009FDB15 /* ProfileImageComponentControlPanelViewController.swift */; };
A78DAE901A8018B5009FDB15 /* NonVibrantImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A78DAE8F1A8018B5009FDB15 /* NonVibrantImageView.swift */; };
A78DAE921A817000009FDB15 /* blackUnderlineTemplate@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A78DAE911A817000009FDB15 /* blackUnderlineTemplate@2x.png */; };
A78DAE941A82320B009FDB15 /* SetupHandleTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = A78DAE931A82320B009FDB15 /* SetupHandleTextField.swift */; };
A7A14C631A82560000586EAD /* StepOneView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7A14C621A82560000586EAD /* StepOneView.swift */; };
A7CC1FFA1A6C8FEB00B49AA9 /* MASShortcut.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7CC1FF91A6C8FEB00B49AA9 /* MASShortcut.framework */; };
A7CC20071A6C992F00B49AA9 /* SwiftyJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7CC20061A6C992F00B49AA9 /* SwiftyJSON.swift */; };
A7CD7F121A6FBB2400BE31D6 /* node.js in Resources */ = {isa = PBXBuildFile; fileRef = A7CD7F111A6FBB2400BE31D6 /* node.js */; };
......@@ -117,6 +119,8 @@
A78DAE8B1A800177009FDB15 /* ProfileImageComponentControlPanelViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileImageComponentControlPanelViewController.swift; sourceTree = "<group>"; };
A78DAE8F1A8018B5009FDB15 /* NonVibrantImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NonVibrantImageView.swift; sourceTree = "<group>"; };
A78DAE911A817000009FDB15 /* blackUnderlineTemplate@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "blackUnderlineTemplate@2x.png"; sourceTree = "<group>"; };
A78DAE931A82320B009FDB15 /* SetupHandleTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SetupHandleTextField.swift; sourceTree = "<group>"; };
A7A14C621A82560000586EAD /* StepOneView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StepOneView.swift; sourceTree = "<group>"; };
A7CC1FF91A6C8FEB00B49AA9 /* MASShortcut.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MASShortcut.framework; path = "../../../../../Library/Developer/Xcode/DerivedData/Heartbeat-bwptofoniwaoqzcgkxzhjtbmtjak/Build/Products/Debug/MASShortcut.framework"; sourceTree = "<group>"; };
A7CC1FFB1A6C8FF700B49AA9 /* SwiftyJSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftyJSON.framework; path = ../../sandbox/SwiftyJSON/build/Debug/SwiftyJSON.framework; sourceTree = "<group>"; };
A7CC1FFD1A6C901400B49AA9 /* SwiftyJSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftyJSON.framework; path = ../../sandbox/SwiftyJSON/build/Debug/SwiftyJSON.framework; sourceTree = "<group>"; };
......@@ -200,6 +204,8 @@
A760C98F1A75A51100E84890 /* IndieNameFormatter.swift */,
A7F0320B1A76F35A00F3A28E /* SetupProgressIndicatorViewController.swift */,
A7F0320D1A77D67500F3A28E /* SetupMessageViewController.swift */,
A78DAE931A82320B009FDB15 /* SetupHandleTextField.swift */,
A7A14C621A82560000586EAD /* StepOneView.swift */,
);
name = Steps;
sourceTree = "<group>";
......@@ -598,6 +604,7 @@
buildActionMask = 2147483647;
files = (
A70634BB1A63114200A75BC0 /* StepOneViewController.swift in Sources */,
A7A14C631A82560000586EAD /* StepOneView.swift in Sources */,
A74CC6611A668A7B0083B288 /* Helpers.swift in Sources */,
A7E7D7BA1A616B1E003501C1 /* ContentViewController.swift in Sources */,
A7CC20071A6C992F00B49AA9 /* SwiftyJSON.swift in Sources */,
......@@ -624,6 +631,7 @@
A7E7D7B31A616B0B003501C1 /* HorizontalSplitViewController.swift in Sources */,
A7F0320C1A76F35A00F3A28E /* SetupProgressIndicatorViewController.swift in Sources */,
A78DAE8D1A800177009FDB15 /* ProfileImageComponentControlPanelViewController.swift in Sources */,
A78DAE941A82320B009FDB15 /* SetupHandleTextField.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -655,7 +655,7 @@
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<window key="window" title="Heartbeat" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="159" y="73" width="1024" height="560"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
......@@ -1146,7 +1146,7 @@
<scene sceneID="7ju-kb-m8c">
<objects>
<viewController title="Select your account" storyboardIdentifier="Step1" id="4K3-FT-bB9" customClass="StepOneViewController" customModule="Heartbeat" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="Ys6-dQ-Qf4">
<view key="view" id="Ys6-dQ-Qf4" customClass="StepOneView" customModule="Heartbeat" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="590" height="487"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
......@@ -1157,20 +1157,25 @@
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<accessibility description="Greeting"/>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="RGu-J6-FTj">
<rect key="frame" x="218" y="188" width="154" height="50"/>
<rect key="frame" x="113" y="188" width="364" height="50"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="150" id="27u-28-Wva"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="360" id="27u-28-Wva"/>
<constraint firstAttribute="height" constant="50" id="366-2v-3I9"/>
<constraint firstAttribute="width" priority="250" constant="150" id="c32-WG-mbg"/>
<constraint firstAttribute="width" priority="250" constant="360" id="c32-WG-mbg"/>
</constraints>
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" alignment="center" placeholderString="aral" allowsEditingTextAttributes="YES" id="fqq-U0-DME">
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" alignment="center" placeholderString="(what shall we call you?)" allowsEditingTextAttributes="YES" id="fqq-U0-DME">
<customFormatter key="formatter" id="BDp-cE-Jbv" customClass="IndieNameFormatter" customModule="Heartbeat" customModuleProvider="target"/>
<font key="font" size="32" name="AvenirNext-Regular"/>
<font key="font" size="32" name="AvenirNext-Italic"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<accessibility description="Handle" help="Sets the account handle you want to use on Indie."/>
<connections>
<accessibilityConnection property="title" destination="UBx-uQ-GES" id="aCS-60-gxi"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="pwd-bE-SCo">
<rect key="frame" x="218" y="437" width="154" height="50"/>
......@@ -1192,13 +1197,15 @@
<constraint firstAttribute="height" constant="102" id="JOV-uv-IrJ"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="indie-logo" id="tX9-lU-26D"/>
<accessibility description="Indie logo"/>
</imageView>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="fJN-Te-9NB">
<rect key="frame" x="220" y="175" width="150" height="5"/>
<rect key="frame" x="115" y="175" width="360" height="5"/>
<constraints>
<constraint firstAttribute="height" constant="5" id="j0e-p0-RWv"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="axesIndependently" image="blackUnderlineTemplate" id="d60-Xh-4th"/>
<accessibility description="Underline"/>
</imageView>
</subviews>
<constraints>
......@@ -1216,8 +1223,10 @@
<constraint firstItem="Q14-lB-euK" firstAttribute="top" secondItem="Ys6-dQ-Qf4" secondAttribute="top" constant="53" id="nFL-WK-rk0"/>
<constraint firstItem="RGu-J6-FTj" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Ys6-dQ-Qf4" secondAttribute="leading" constant="20" id="t8u-Fi-SVg"/>
</constraints>
<accessibility description="Account Setup" help="Step one of two"/>
</view>
<connections>
<outlet property="greetingLabel" destination="UBx-uQ-GES" id="xdj-Qj-OJK"/>
<outlet property="nameTextField" destination="RGu-J6-FTj" id="gAD-So-D7Q"/>
<outlet property="nameTextFieldCopyForMeasurements" destination="pwd-bE-SCo" id="s9H-Cm-zeB"/>
<outlet property="nameTextFieldWidthConstraint" destination="27u-28-Wva" id="fiN-Uq-hpS"/>
......@@ -1698,7 +1707,7 @@
<rect key="frame" x="1" y="1" width="166" height="79"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<ikImageView autoresizesSubviews="NO" wantsLayer="YES" fixedFrame="YES" editable="YES" translatesAutoresizingMaskIntoConstraints="NO" id="is3-Tg-ZE0">
<ikImageView autoresizesSubviews="NO" wantsLayer="YES" fixedFrame="YES" zoomFactor="0.0" editable="YES" translatesAutoresizingMaskIntoConstraints="NO" id="is3-Tg-ZE0">
<rect key="frame" x="0.0" y="0.0" width="150" height="150"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<connections>
......
......@@ -12,6 +12,19 @@ import Foundation
// Helpers
//
//
// Accessibility
//
func makeAccessibilityAnnouncement(message:String)
{
NSAccessibilityPostNotificationWithUserInfo(NSApp.mainWindow, NSAccessibilityAnnouncementRequestedNotification, [NSAccessibilityAnnouncementKey: message])
}
//
// Other
//
func delay(delay:Double, closure:()->())
{
//
......
//
// SetupHandleTextField.swift
// Heartbeat
//
// Created by Aral Balkan on 04/02/2015.
// Copyright (c) 2015 Ind.ie. All rights reserved.
//
import Cocoa
class SetupHandleTextField: NSTextField
{
override func accessibilityAttributeValue(attribute: String) -> AnyObject? {
println("ACCESSIBILITY: \(attribute)")
if (attribute == NSAccessibilityStringForRangeParameterizedAttribute as String) {
return "Ducks and more ducks"
} else {
return super.accessibilityAttributeValue(attribute)
}
}
override func accessibilityAttributeValue(attribute: String, forParameter parameter: AnyObject?) -> AnyObject
{
println("ACCESS:::: \(attribute) - \(parameter)")
var attributedStringToReturn:NSAttributedString
attributedStringToReturn = (attribute == (NSAccessibilityAttributedStringForRangeParameterizedAttribute as String)) ? NSAttributedString(string: "Enter the handle you want to use on Indie") : (super.accessibilityAttributeValue(attribute, forParameter: parameter) as NSAttributedString)
return attributedStringToReturn
}
}
......@@ -14,6 +14,11 @@ class SetupMessageViewController: NSViewController
@IBOutlet weak var titleLabel: NSTextField!
@IBOutlet weak var messageLabel: NSTextField!
override func accessibilityIsIgnored() -> Bool {
return false
}
override func viewDidLoad()
{
super.viewDidLoad()
......@@ -59,6 +64,14 @@ class SetupMessageViewController: NSViewController
}
func show() {
// Make accessibility announcement.
var messageBodyToRead = messageBody.stringByReplacingOccurrencesOfString("-", replacement: "-dash-") // Help with pronunciation (TODO: localise)
messageBodyToRead = messageBodyToRead.stringByReplacingOccurrencesOfString("ind.ie", replacement: "i.n.d-dot-i.e") // (Question: will this make it harder for people with Braille?)
messageBodyToRead = messageBodyToRead.stringByReplacingOccurrencesOfString("/", replacement: "-forward-slash-") //
let messageToRead:String = "\(messageTitle) \(messageBodyToRead)"
makeAccessibilityAnnouncement(messageToRead)
let fade = CABasicAnimation(keyPath: "opacity")
fade.fromValue = 0.0
fade.toValue = 1.0
......
......@@ -30,6 +30,9 @@ class SetupProgressIndicatorViewController: NSViewController {
}
func show() {
// Make accessibility announcement
makeAccessibilityAnnouncement(self.message.stringValue)
progressIndicator.startAnimation(self)
self.view.hidden = false
}
......
......@@ -248,7 +248,7 @@ class SetupViewController: NSViewController, SetupDelegate {
func showMessage(title: String, body: String)
{
message.show(title, body: body)
hideProgress()
}
......
//
// StepOneView.swift
// Heartbeat
//
// Created by Aral Balkan on 04/02/2015.
// Copyright (c) 2015 Ind.ie. All rights reserved.
//
import Cocoa
class StepOneView: NSView {
override func accessibilityIsIgnored() -> Bool {
return false
}
}
......@@ -11,6 +11,7 @@ import Cocoa
class StepOneViewController: SetupStepViewController
{
@IBOutlet weak var greetingLabel: NSTextField!
@IBOutlet weak var nameTextField: NSTextField!
@IBOutlet weak var nameTextFieldCopyForMeasurements: NSTextField!
@IBOutlet weak var nameTextFieldWidthConstraint: NSLayoutConstraint!
......@@ -22,6 +23,12 @@ class StepOneViewController: SetupStepViewController
{
super.viewDidLoad()
self.view.setAccessibilityLabel("Setup: step one of two. Choose your Indie handle")
self.view.setAccessibilityRole(NSAccessibilityGroupRole)
nameTextField.accessibilitySetOverrideValue(self.greetingLabel, forAttribute: NSAccessibilityTitleUIElementAttribute)
// greetingLabel.setAccessibilityServesAsTitleForUIElements([nameTextField])
// nameTextField.setAccessibilityLabelUIElements([greetingLabel])
nameTextField.focusRingType = NSFocusRingType.None
// NSNotificationCenter.defaultCenter().when(youGet: NSControlTextDidChangeNotification, call: "textDidChange:", on: self)
......@@ -32,7 +39,7 @@ class StepOneViewController: SetupStepViewController
nameTextFieldCopyForMeasurements.hidden = true
// Setup an initial timer
self.timer = NSTimer(timeInterval: 0.1, target: self, selector: "checkIfNameExists", userInfo: nil, repeats: false)
self.timer = NSTimer(timeInterval: 0.2, target: self, selector: "checkIfNameExists", userInfo: nil, repeats: false)
}
......@@ -64,7 +71,7 @@ class StepOneViewController: SetupStepViewController
func textDidChange(notification:NSNotification)
{
//
// Use the copy of the text field to measure how large it is when sized to fit.
// Use the copy of the text field to measure h ow large it is when sized to fit.
// (We use a copy so that we don’t affect the actual one and can easily
// set a minimum width that is larger than the size to fit size of the text field.)
//
......@@ -73,9 +80,9 @@ class StepOneViewController: SetupStepViewController
var textFieldCopyWidth = NSWidth(nameTextFieldCopyForMeasurements.frame)
// Set the minimum width.
if textFieldCopyWidth < 150.0
if textFieldCopyWidth < 360.0
{
textFieldCopyWidth = 150.0
textFieldCopyWidth = 360.0
}
nameTextFieldWidthConstraint.constant = textFieldCopyWidth
......@@ -125,7 +132,7 @@ class StepOneViewController: SetupStepViewController
println("Retrieved response from Waystone. handleIsAvailable: \(handleIsAvailable)")
// DEBUG: Add a delay so we can see it. Make this into a control panel setting.
delay(0.5)
delay(1.5)
{
if (handleIsAvailable)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment