From 0e21fb3eea4a80cc4ff0d3448c3821d318734b33 Mon Sep 17 00:00:00 2001 From: Jonas Gessner Date: Sat, 23 May 2015 23:37:02 +0200 Subject: [PATCH] 1.2.7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Added Voice Over support. --- JGProgressHUD.podspec | 4 +- JGProgressHUD/JGProgressHUD/JGProgressHUD.m | 6 +++ .../JGProgressHUDErrorIndicatorView.m | 4 ++ .../JGProgressHUDIndeterminateIndicatorView.m | 4 ++ .../JGProgressHUDIndicatorView.h | 15 ++++++ .../JGProgressHUDIndicatorView.m | 46 +++++++++++++++++++ .../JGProgressHUDSuccessIndicatorView.m | 4 ++ README.md | 11 +++-- 8 files changed, 87 insertions(+), 7 deletions(-) diff --git a/JGProgressHUD.podspec b/JGProgressHUD.podspec index 583fc40..7680b71 100644 --- a/JGProgressHUD.podspec +++ b/JGProgressHUD.podspec @@ -1,14 +1,14 @@ Pod::Spec.new do |s| s.name = "JGProgressHUD" - s.version = "1.2.6" + s.version = "1.2.7" s.summary = "Powerful and modern progress HUD for iOS." s.homepage = "https://github.com/JonasGessner/JGProgressHUD" s.license = { :type => "MIT", :file => "LICENSE.txt" } s.author = "Jonas Gessner" s.social_media_url = "http://twitter.com/JonasGessner" s.platform = :ios, "5.0" - s.source = { :git => "https://github.com/JonasGessner/JGProgressHUD.git", :tag => "v1.2.6" } + s.source = { :git => "https://github.com/JonasGessner/JGProgressHUD.git", :tag => "v1.2.7" } s.source_files = "JGProgressHUD/JGProgressHUD/*.{h,m}" s.resource = "JGProgressHUD/JGProgressHUD/JGProgressHUD Resources.bundle" s.frameworks = "Foundation", "UIKit", "QuartzCore" diff --git a/JGProgressHUD/JGProgressHUD/JGProgressHUD.m b/JGProgressHUD/JGProgressHUD/JGProgressHUD.m index 6cf0aea..2235cf6 100755 --- a/JGProgressHUD/JGProgressHUD/JGProgressHUD.m +++ b/JGProgressHUD/JGProgressHUD/JGProgressHUD.m @@ -359,6 +359,10 @@ - (void)cleanUpAfterPresentation { _dismissAfterTransitionFinished = NO; _dismissAfterTransitionFinishedWithAnimation = NO; } + + if (UIAccessibilityIsVoiceOverRunning()) { + UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self); + } } - (void)showInView:(UIView *)view { @@ -632,6 +636,7 @@ - (UILabel *)textLabel { _textLabel.numberOfLines = 0; [_textLabel addObserver:self forKeyPath:@"text" options:(NSKeyValueObservingOptions)kNilOptions context:NULL]; [_textLabel addObserver:self forKeyPath:@"font" options:(NSKeyValueObservingOptions)kNilOptions context:NULL]; + _textLabel.isAccessibilityElement = YES; [self.contentView addSubview:_textLabel]; } @@ -649,6 +654,7 @@ - (UILabel *)detailTextLabel { _detailTextLabel.numberOfLines = 0; [_detailTextLabel addObserver:self forKeyPath:@"text" options:(NSKeyValueObservingOptions)kNilOptions context:NULL]; [_detailTextLabel addObserver:self forKeyPath:@"font" options:(NSKeyValueObservingOptions)kNilOptions context:NULL]; + _detailTextLabel.isAccessibilityElement = YES; [self.contentView addSubview:_detailTextLabel]; } diff --git a/JGProgressHUD/JGProgressHUD/JGProgressHUDErrorIndicatorView.m b/JGProgressHUD/JGProgressHUD/JGProgressHUDErrorIndicatorView.m index 37ae131..c3165f5 100644 --- a/JGProgressHUD/JGProgressHUD/JGProgressHUDErrorIndicatorView.m +++ b/JGProgressHUD/JGProgressHUD/JGProgressHUDErrorIndicatorView.m @@ -27,4 +27,8 @@ - (instancetype)init { return [self initWithContentView:nil]; } +- (void)updateAccessibility { + self.accessibilityLabel = NSLocalizedString(@"Error",); +} + @end diff --git a/JGProgressHUD/JGProgressHUD/JGProgressHUDIndeterminateIndicatorView.m b/JGProgressHUD/JGProgressHUD/JGProgressHUDIndeterminateIndicatorView.m index da224f3..6aaa71a 100644 --- a/JGProgressHUD/JGProgressHUD/JGProgressHUDIndeterminateIndicatorView.m +++ b/JGProgressHUD/JGProgressHUD/JGProgressHUDIndeterminateIndicatorView.m @@ -32,4 +32,8 @@ - (void)setColor:(UIColor *)color { [(UIActivityIndicatorView *)self.contentView setColor:color]; } +- (void)updateAccessibility { + self.accessibilityLabel = NSLocalizedString(@"Indeterminate progress",); +} + @end diff --git a/JGProgressHUD/JGProgressHUD/JGProgressHUDIndicatorView.h b/JGProgressHUD/JGProgressHUD/JGProgressHUDIndicatorView.h index 83b47c6..f3d0835 100755 --- a/JGProgressHUD/JGProgressHUD/JGProgressHUDIndicatorView.h +++ b/JGProgressHUD/JGProgressHUD/JGProgressHUDIndicatorView.h @@ -40,4 +40,19 @@ */ - (void)setProgress:(float)progress animated:(BOOL)animated; +/** + Schedules an accessibility update on the next run loop. + */ +- (void)setNeedsAccessibilityUpdate; + +/** + Runs @c updateAccessibility immediately if an accessibility update has been scheduled (through @c setNeedsAccessibilityUpdate) but has not executed yet. + */ +- (void)updateAccessibilityIfNeeded; + +/** + Override to set custom accessibility properties. This method gets called once when initializing the view and after calling @c setNeedsAccessibilityUpdate. + */ +- (void)updateAccessibility; + @end diff --git a/JGProgressHUD/JGProgressHUD/JGProgressHUDIndicatorView.m b/JGProgressHUD/JGProgressHUD/JGProgressHUDIndicatorView.m index abaa566..b066e62 100755 --- a/JGProgressHUD/JGProgressHUD/JGProgressHUDIndicatorView.m +++ b/JGProgressHUD/JGProgressHUD/JGProgressHUDIndicatorView.m @@ -9,6 +9,18 @@ #import "JGProgressHUDIndicatorView.h" #import "JGProgressHUD.h" +@interface JGProgressHUDIndicatorView () { + BOOL _accessibilityUpdateScheduled; +} + ++ (void)runBlock:(void (^)(void))block; + +@end + +NS_INLINE void runOnNextRunLoop(void (^block)(void)) { + [[NSRunLoop currentRunLoop] performSelector:@selector(runBlock:) target:[JGProgressHUDIndicatorView class] argument:(id)block order:0 modes:@[NSRunLoopCommonModes]]; +} + @implementation JGProgressHUDIndicatorView #pragma mark - Initializers @@ -27,6 +39,9 @@ - (instancetype)initWithContentView:(UIView *)contentView { self.opaque = NO; self.backgroundColor = [UIColor clearColor]; + self.isAccessibilityElement = YES; + [self setNeedsAccessibilityUpdate]; + if (contentView) { _contentView = contentView; @@ -36,6 +51,35 @@ - (instancetype)initWithContentView:(UIView *)contentView { return self; } +#pragma mark - Accessibility + ++ (void)runBlock:(void (^)(void))block { + if (block != nil) { + block(); + } +} + +- (void)setNeedsAccessibilityUpdate { + if (!_accessibilityUpdateScheduled) { + _accessibilityUpdateScheduled = YES; + + runOnNextRunLoop(^{ + [self updateAccessibilityIfNeeded]; + }); + } +} + +- (void)updateAccessibilityIfNeeded { + if (_accessibilityUpdateScheduled) { + [self updateAccessibility]; + _accessibilityUpdateScheduled = NO; + } +} + +- (void)updateAccessibility { + self.accessibilityLabel = [NSLocalizedString(@"Loading",) stringByAppendingFormat:@" %.f %%", self.progress]; +} + #pragma mark - Getters & Setters - (void)setProgress:(float)progress { @@ -48,6 +92,8 @@ - (void)setProgress:(float)progress animated:(BOOL __unused)animated { } _progress = progress; + + [self setNeedsAccessibilityUpdate]; } @end diff --git a/JGProgressHUD/JGProgressHUD/JGProgressHUDSuccessIndicatorView.m b/JGProgressHUD/JGProgressHUD/JGProgressHUDSuccessIndicatorView.m index ef1c7c6..a9ab832 100644 --- a/JGProgressHUD/JGProgressHUD/JGProgressHUDSuccessIndicatorView.m +++ b/JGProgressHUD/JGProgressHUD/JGProgressHUDSuccessIndicatorView.m @@ -27,4 +27,8 @@ - (instancetype)init { return [self initWithContentView:nil]; } +- (void)updateAccessibility { + self.accessibilityLabel = NSLocalizedString(@"Success",); +} + @end diff --git a/README.md b/README.md index a260c85..ce7a49d 100644 --- a/README.md +++ b/README.md @@ -16,21 +16,22 @@ Overview • Backward compatibility to iOS 5.
• Well documented and maintained.
• Detects and repositions when Keyboards appear/disappear.
+• Voice Over/`UIAccessibility` support.
• And most importantly, it looks good!

The JGProgressHUD Tests example project contains all kinds of different uses of JGProgressHUD. Check out the code and see how much JGProgressHUD can do!
-#####Current Version: 1.2.6 -[![GitHub license](https://img.shields.io/github/license/JonasGessner/JGProgressHUD.svg)]()
-[![CocoaPods](https://img.shields.io/cocoapods/v/JGProgressHUD.svg)]() +#####Current Version: 1.2.7 +![GitHub license](https://img.shields.io/github/license/JonasGessner/JGProgressHUD.svg)
+![CocoaPods](https://img.shields.io/cocoapods/v/JGProgressHUD.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ##Customization: ###Styles: JGProgressHUD can be displayed in 3 styles:
Extra Light
-• Light
-• Dark
+• Light
+• Dark
###Indicator Views: By default a HUD will display an indeterminate progress indicator. You can not show an indicator view at all by setting the `indicatorView` property to nil. These indicator views are available: